فهرست منبع

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 11 سال پیش
والد
کامیت
23c7bc958a
3فایلهای تغییر یافته به همراه30 افزوده شده و 30 حذف شده
  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 %

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 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 %

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است