@glitchr/stickyjs 1.0.27 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/js/sticky.js +16 -9
package/package.json
CHANGED
package/src/js/sticky.js
CHANGED
|
@@ -207,7 +207,8 @@ $.fn.serializeObject = function () {
|
|
|
207
207
|
"right":false ,
|
|
208
208
|
},
|
|
209
209
|
|
|
210
|
-
"
|
|
210
|
+
"passive": false,
|
|
211
|
+
"scrollpercent" : true ,
|
|
211
212
|
|
|
212
213
|
"scrollsnap" : true ,
|
|
213
214
|
"scrollsnap_start" : "start", //start, center, end
|
|
@@ -804,7 +805,6 @@ $.fn.serializeObject = function () {
|
|
|
804
805
|
|
|
805
806
|
Sticky.enableScroll = function(el = window) {
|
|
806
807
|
|
|
807
|
-
console.log(el);
|
|
808
808
|
// left: 37, up: 38, right: 39, down: 40,
|
|
809
809
|
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
|
|
810
810
|
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
|
|
@@ -825,9 +825,10 @@ $.fn.serializeObject = function () {
|
|
|
825
825
|
}));
|
|
826
826
|
} catch(e) {}
|
|
827
827
|
|
|
828
|
-
var wheelOpt = supportsPassive ? { passive:
|
|
828
|
+
var wheelOpt = supportsPassive ? { passive: false } : false;
|
|
829
829
|
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel.preventDefault' : 'mousewheel.preventDefault';
|
|
830
830
|
|
|
831
|
+
el.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
|
|
831
832
|
el.addEventListener(wheelEvent, preventDefault, wheelOpt); // modern desktop
|
|
832
833
|
el.addEventListener('touchmove.preventDefault', preventDefault, wheelOpt); // mobile
|
|
833
834
|
el.addEventListener('keydown.preventDefault', preventDefaultForScrollKeys, false);
|
|
@@ -856,9 +857,10 @@ $.fn.serializeObject = function () {
|
|
|
856
857
|
}));
|
|
857
858
|
} catch(e) {}
|
|
858
859
|
|
|
859
|
-
var wheelOpt = supportsPassive ? { passive:
|
|
860
|
+
var wheelOpt = supportsPassive ? { passive: false } : false;
|
|
860
861
|
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel.preventDefault' : 'mousewheel.preventDefault';
|
|
861
862
|
|
|
863
|
+
el.removeEventListener('DOMMouseScroll.preventDefault', preventDefault, false);
|
|
862
864
|
el.removeEventListener(wheelEvent, preventDefault, wheelOpt);
|
|
863
865
|
el.removeEventListener('touchmove.preventDefault', preventDefault, wheelOpt);
|
|
864
866
|
el.removeEventListener('keydown.preventDefault', preventDefaultForScrollKeys, false);
|
|
@@ -989,6 +991,8 @@ $.fn.serializeObject = function () {
|
|
|
989
991
|
if (Settings.debug) console.log(show,"Sticky magnetic:", scrollSnap, scrollSnapStart, scrollSnapProximity);
|
|
990
992
|
if(!Settings.ready) return;
|
|
991
993
|
|
|
994
|
+
if(Sticky.get("passive") == true) return;
|
|
995
|
+
|
|
992
996
|
var scrollSnap = Sticky.get("scrollsnap");
|
|
993
997
|
if(!scrollSnap) return;
|
|
994
998
|
|
|
@@ -1595,7 +1599,9 @@ $.fn.serializeObject = function () {
|
|
|
1595
1599
|
|
|
1596
1600
|
Sticky.reset(el);
|
|
1597
1601
|
|
|
1598
|
-
|
|
1602
|
+
if(Sticky.get("passive") == false)
|
|
1603
|
+
$(el).on('wheel.sticky', Sticky.onWheel);
|
|
1604
|
+
|
|
1599
1605
|
$(el).on('scrolldelta.sticky', Sticky.onScrollDelta);
|
|
1600
1606
|
$(el).on('scrolldelta.sticky', Sticky.debounce(Sticky.onScrollDebounce, 1000*Sticky.parseDuration(Sticky.get("debounce"))));
|
|
1601
1607
|
|
|
@@ -1718,7 +1724,7 @@ $.fn.serializeObject = function () {
|
|
|
1718
1724
|
if(autoscrollTimeout != undefined) clearTimeout(autoscrollTimeout);
|
|
1719
1725
|
$(scroller).prop("user-scroll", true);
|
|
1720
1726
|
$(scroller).stop();
|
|
1721
|
-
}
|
|
1727
|
+
});
|
|
1722
1728
|
|
|
1723
1729
|
$(scroller).on("mouseleave.autoscroll touchend.autoscroll");
|
|
1724
1730
|
$(scroller).on("mouseleave.autoscroll touchend.autoscroll", function() {
|
|
@@ -1729,11 +1735,12 @@ $.fn.serializeObject = function () {
|
|
|
1729
1735
|
$(scroller).data("autoscroll-prevent", "true");
|
|
1730
1736
|
$(scroller).off("mouseleave.autoscroll touchend.autoscroll");
|
|
1731
1737
|
}
|
|
1732
|
-
}
|
|
1738
|
+
});
|
|
1733
1739
|
|
|
1734
1740
|
$(scroller).on("onbeforeunload.autoscroll");
|
|
1735
1741
|
$(scroller).on("onbeforeunload.autoscroll", function() {
|
|
1736
1742
|
|
|
1743
|
+
$(this).off("mousewheel.autoscroll touchstart.autoscroll");
|
|
1737
1744
|
$(this).off("mouseenter.autoscroll touchstart.autoscroll");
|
|
1738
1745
|
$(this).off("mouseleave.autoscroll touchend.autoscroll");
|
|
1739
1746
|
$(this).off("scroll.autoscroll");
|
|
@@ -1741,7 +1748,7 @@ $.fn.serializeObject = function () {
|
|
|
1741
1748
|
|
|
1742
1749
|
var scrollerWindow = $(this).closestScrollableWindow();
|
|
1743
1750
|
$(scrollerWindow).off("scroll.autoscroll");
|
|
1744
|
-
}
|
|
1751
|
+
});
|
|
1745
1752
|
}
|
|
1746
1753
|
|
|
1747
1754
|
//
|
|
@@ -1757,7 +1764,7 @@ $.fn.serializeObject = function () {
|
|
|
1757
1764
|
|
|
1758
1765
|
$(this).prop("user-scroll", true);
|
|
1759
1766
|
$(this).stop();
|
|
1760
|
-
}
|
|
1767
|
+
});
|
|
1761
1768
|
|
|
1762
1769
|
if (Settings.debug) console.log("Autoscroll reverse delay applied is \"" + reverseDelay + "\".");
|
|
1763
1770
|
setTimeout(() => Sticky.scrollTo({
|