11/*
22 * animate.js - animate-dynamic.ga
3- * Version - v2.16.7
3+ * Version - v2.18.8
44 * Licensed under the MIT license - https://opensource.org/licenses/MIT
55
66 * Copyright (c) 2021 Mohammed Khurram (KodingKhurram)
@@ -51,7 +51,7 @@ function view_Animations(){
5151 var ani_classes = get_aniClasses ( this ) ;
5252
5353 //Check visibility then animate
54- if ( isScrolledIntoView ( this ) === true ) {
54+ if ( isScrolledIntoView ( this ) === "full" ) {
5555 if ( ! $ ( this ) . hasClass ( "aniUtil_animating" ) && ! $ ( this ) . hasClass ( "animate__animated" ) ) {
5656 if ( $ ( this ) . hasClass ( "aniUtil_dramatic" ) ) {
5757 $ ( this ) . css ( "opacity" , 100 ) ;
@@ -63,7 +63,7 @@ function view_Animations(){
6363 } ) ;
6464 }
6565 }
66- else {
66+ else if ( isScrolledIntoView ( this ) === "no" ) {
6767 if ( $ ( this ) . hasClass ( "aniUtil_active" ) && ! $ ( this ) . hasClass ( "aniUtil_animating" ) ) {
6868 if ( $ ( this ) . hasClass ( "aniUtil_dramatic" ) ) {
6969 $ ( this ) . css ( "opacity" , 0 ) ;
@@ -77,12 +77,12 @@ function view_Animations(){
7777 //aniCus_tubeLight
7878 $ ( "*[class*='aniCus_tubeLight']:not([class*='aniUtil_onClick']):not([class*='aniUtil_onMouse']):not([class*='aniUtil_onKey']):not([class*='aniUtil_disabled'])" ) . each ( function ( ) {
7979 //Check visibility then animate
80- if ( isScrolledIntoView ( this ) === true ) {
80+ if ( isScrolledIntoView ( this ) === "full" ) {
8181 if ( ! $ ( this ) . hasClass ( "aniUtil_animating" ) && ! $ ( this ) . hasClass ( "animate__animated" ) ) {
8282 aniCus_tubeLight ( this , 1 ) ;
8383 }
8484 }
85- else {
85+ else if ( isScrolledIntoView ( this ) === "no" ) {
8686 if ( $ ( this ) . hasClass ( "aniUtil_active" ) && ! $ ( this ) . hasClass ( "aniUtil_animating" ) ) {
8787 if ( $ ( this ) . hasClass ( "aniUtil_dramatic" ) ) {
8888 $ ( this ) . css ( "opacity" , 0 ) ;
@@ -99,12 +99,12 @@ function view_Animations(){
9999 var aniOut_classes = outInClasses [ 0 ] ;
100100 var aniIn_classes = outInClasses [ 1 ] ;
101101 //Check visibility then animate
102- if ( isScrolledIntoView ( this ) === true ) {
102+ if ( isScrolledIntoView ( this ) === "full" ) {
103103 if ( ! $ ( this ) . hasClass ( "aniUtil_animating" ) && ! $ ( this ) . hasClass ( "animate__animated" ) ) {
104104 aniCus_OutIn ( this , 1 , aniOut_classes , aniIn_classes ) ;
105105 }
106106 }
107- else {
107+ else if ( isScrolledIntoView ( this ) === "no" ) {
108108 if ( $ ( this ) . hasClass ( "aniUtil_active" ) && ! $ ( this ) . hasClass ( "aniUtil_animating" ) ) {
109109 if ( $ ( this ) . hasClass ( "aniUtil_dramatic" ) ) {
110110 $ ( this ) . css ( "opacity" , 0 ) ;
@@ -393,7 +393,11 @@ function isScrolledIntoView(elem) {
393393 var elemTop = rect . top ;
394394 var elemBottom = rect . bottom ;
395395 //Completely visible
396- return ( ( elemTop >= 0 ) && ( elemBottom <= window . innerHeight ) ) ;
396+ if ( ( elemTop >= 0 && elemBottom <= window . innerHeight ) ) return "full" ;
397+ //Partially visible
398+ else if ( ( elemTop < window . innerHeight && elemBottom >= 0 ) ) return "partial" ;
399+ //Not visible
400+ else return "no" ;
397401}
398402
399403//Check if element is scrolled into division view
@@ -758,8 +762,14 @@ function aniUtil_inanimate(elem){
758762//aniUtil_reset()
759763function aniUtil_reset ( elem ) {
760764 //This function resets the animation for a perticular element
761- var reset_classes = get_aniClasses ( elem ) ;
762- $ ( elem ) . removeClass ( reset_classes ) ;
765+ $ ( elem ) . removeClass ( get_aniClasses ( elem ) ) ;
763766 if ( ! $ ( elem ) . hasClass ( "aniUtil_onMouse" ) && ! $ ( elem ) . hasClass ( "aniUtil_onClick" ) && ! $ ( elem ) . is ( '[class*="aniCus_onKey"]' ) )
764767 view_Animations ( ) ;
765768}
769+
770+ //aniUtil_flush
771+ function aniUtil_flush ( elem ) {
772+ //This function flushes the animation classes for a particular element
773+ $ ( elem ) . removeClass ( get_aniClasses ( elem ) ) ;
774+ $ ( elem ) . removeClass ( "ani_" + get_aniClasses ( elem ) . split ( "__" ) [ 2 ] ) ;
775+ }
0 commit comments