Explorar el Código

Offset fix & scroll-down fix

Fixed an issue where the offset was calculated wrong and one where
already shown items where hidden on scroll down
Adam Bouqdib hace 11 años
padre
commit
23c7bc958a
Se han modificado 3 ficheros con 30 adiciones y 30 borrados
  1. 15 15
      dist/jquery.smoove.js
  2. 0 0
      dist/jquery.smoove.min.js
  3. 15 15
      src/jquery.smoove.js

+ 15 - 15
dist/jquery.smoove.js

@@ -113,21 +113,21 @@
             
             $(window).on('load', function() {
                 smooveIt();
-            })
-            
-            // throttle scroll handler
-            .scroll(function() {
-                didScroll = true;
+                
+                // throttle scroll handler
+                $(window).scroll(function() {
+                    didScroll = true;
+                });
+                setInterval(function() {
+                    if ( didScroll ) {
+                        didScroll = false;
+                        var scrolltop = $(window).scrollTop(),
+                            direction = (scrolltop < oldScroll) ? direction = 'up' : 'down';
+                        oldScroll = scrolltop;
+                        smooveIt(direction);
+                    }
+                }, 250);
             });
-            setInterval(function() {
-                if ( didScroll ) {
-                    didScroll = false;
-                    var scrolltop = $(window).scrollTop(),
-                        direction = (scrolltop < oldScroll) ? direction = 'up' : 'down';
-                    oldScroll = scrolltop;
-                    smooveIt(direction);
-                }
-            }, 250);
         }
         
         function smooveIt(direction) {
@@ -136,7 +136,7 @@
                     params = $item.params,
                     height = $(window).height(),
                     // if direction isn't set, set offset to 0 to avoid hiding objects that are above the fold
-                    offset = (direction && !$item.css('opacity')) ? params.offset : 0,
+                    offset = (!direction || direction === 'down' && $item.css('opacity') === '1') ? 0 : params.offset,
                     itemtop = $(window).scrollTop() + height - $item.data('top');
                     
                 // offset in %

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
dist/jquery.smoove.min.js


+ 15 - 15
src/jquery.smoove.js

@@ -108,21 +108,21 @@
             
             $(window).on('load', function() {
                 smooveIt();
-            })
-            
-            // throttle scroll handler
-            .scroll(function() {
-                didScroll = true;
+                
+                // throttle scroll handler
+                $(window).scroll(function() {
+                    didScroll = true;
+                });
+                setInterval(function() {
+                    if ( didScroll ) {
+                        didScroll = false;
+                        var scrolltop = $(window).scrollTop(),
+                            direction = (scrolltop < oldScroll) ? direction = 'up' : 'down';
+                        oldScroll = scrolltop;
+                        smooveIt(direction);
+                    }
+                }, 250);
             });
-            setInterval(function() {
-                if ( didScroll ) {
-                    didScroll = false;
-                    var scrolltop = $(window).scrollTop(),
-                        direction = (scrolltop < oldScroll) ? direction = 'up' : 'down';
-                    oldScroll = scrolltop;
-                    smooveIt(direction);
-                }
-            }, 250);
         }
         
         function smooveIt(direction) {
@@ -131,7 +131,7 @@
                     params = $item.params,
                     height = $(window).height(),
                     // if direction isn't set, set offset to 0 to avoid hiding objects that are above the fold
-                    offset = (direction && !$item.css('opacity')) ? params.offset : 0,
+                    offset = (!direction || direction === 'down' && $item.css('opacity') === '1') ? 0 : params.offset,
                     itemtop = $(window).scrollTop() + height - $item.data('top');
                     
                 // offset in %

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio