@glitchr/stickyjs 1.0.33 → 1.0.34
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 +171 -172
package/package.json
CHANGED
package/src/js/sticky.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// Modern browser: use passive event listeners where appropriate for better performance
|
|
2
|
+
jQuery.event.special.touchstart = { setup: function( _, ns, handle ) { this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); } };
|
|
3
|
+
jQuery.event.special.touchmove = { setup: function( _, ns, handle ) { this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); } };
|
|
4
|
+
jQuery.event.special.wheel = { setup: function( _, ns, handle ) { this.addEventListener("wheel", handle, { passive: true }); } };
|
|
5
|
+
jQuery.event.special.mousewheel = { setup: function( _, ns, handle ) { this.addEventListener("mousewheel", handle, { passive: true }); } };
|
|
6
|
+
|
|
7
|
+
// Sticky.js
|
|
1
8
|
(function(namespace) {
|
|
2
9
|
|
|
3
10
|
namespace.replaceHash = function(newHash, triggerHashChange = true, skipIfEmptyIdentifier = true) {
|
|
@@ -183,7 +190,7 @@ $.fn.serializeObject = function () {
|
|
|
183
190
|
})(this, function () {
|
|
184
191
|
|
|
185
192
|
var Sticky = window.Sticky = {};
|
|
186
|
-
Sticky.version = '
|
|
193
|
+
Sticky.version = '1.0.0';
|
|
187
194
|
|
|
188
195
|
var Settings = Sticky.settings = {
|
|
189
196
|
|
|
@@ -207,7 +214,7 @@ $.fn.serializeObject = function () {
|
|
|
207
214
|
"right":false ,
|
|
208
215
|
},
|
|
209
216
|
|
|
210
|
-
"passive":
|
|
217
|
+
"passive": true,
|
|
211
218
|
"scrollpercent" : true ,
|
|
212
219
|
|
|
213
220
|
"scrollsnap" : true ,
|
|
@@ -307,6 +314,7 @@ $.fn.serializeObject = function () {
|
|
|
307
314
|
Sticky.epsilon = function(x1, x0) { return Math.abs(x1-x0) < 1; }
|
|
308
315
|
Sticky.reset = function(el = window) {
|
|
309
316
|
|
|
317
|
+
|
|
310
318
|
el = el === window ? document.documentElement : el;
|
|
311
319
|
el = $(el).length ? $(el)[0] : undefined;
|
|
312
320
|
|
|
@@ -345,7 +353,6 @@ $.fn.serializeObject = function () {
|
|
|
345
353
|
Settings.ready = true;
|
|
346
354
|
|
|
347
355
|
if (Settings.debug) console.log("Sticky is ready.");
|
|
348
|
-
if (Settings.debug) console.log("(padding = ", Sticky.getScrollPadding(), ")");
|
|
349
356
|
dispatchEvent(new Event('sticky:ready'));
|
|
350
357
|
|
|
351
358
|
return this;
|
|
@@ -818,20 +825,11 @@ $.fn.serializeObject = function () {
|
|
|
818
825
|
}
|
|
819
826
|
}
|
|
820
827
|
|
|
821
|
-
// modern Chrome requires { passive: false } when adding event
|
|
822
|
-
var supportsPassive = false;
|
|
823
|
-
try {
|
|
824
|
-
window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
|
|
825
|
-
get: function () { supportsPassive = true; }
|
|
826
|
-
}));
|
|
827
|
-
} catch(e) {}
|
|
828
|
-
|
|
829
|
-
var wheelOpt = supportsPassive ? { passive: false } : false;
|
|
830
828
|
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel.preventDefault' : 'mousewheel.preventDefault';
|
|
831
829
|
|
|
832
830
|
el.addEventListener('DOMMouseScroll', preventDefault, false); // older FF
|
|
833
|
-
el.addEventListener(wheelEvent, preventDefault
|
|
834
|
-
el.addEventListener('touchmove.preventDefault', preventDefault
|
|
831
|
+
el.addEventListener(wheelEvent, preventDefault); // modern desktop
|
|
832
|
+
el.addEventListener('touchmove.preventDefault', preventDefault); // mobile
|
|
835
833
|
el.addEventListener('keydown.preventDefault', preventDefaultForScrollKeys, false);
|
|
836
834
|
scrollState[el] = true;
|
|
837
835
|
}
|
|
@@ -850,20 +848,11 @@ $.fn.serializeObject = function () {
|
|
|
850
848
|
}
|
|
851
849
|
}
|
|
852
850
|
|
|
853
|
-
// modern Chrome requires { passive: false } when adding event
|
|
854
|
-
var supportsPassive = false;
|
|
855
|
-
try {
|
|
856
|
-
window.addEventListener("test", null, Object.defineProperty({}, 'passive', {
|
|
857
|
-
get: function () { supportsPassive = true; }
|
|
858
|
-
}));
|
|
859
|
-
} catch(e) {}
|
|
860
|
-
|
|
861
|
-
var wheelOpt = supportsPassive ? { passive: false } : false;
|
|
862
851
|
var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel.preventDefault' : 'mousewheel.preventDefault';
|
|
863
852
|
|
|
864
853
|
el.removeEventListener('DOMMouseScroll.preventDefault', preventDefault, false);
|
|
865
|
-
el.removeEventListener(wheelEvent, preventDefault
|
|
866
|
-
el.removeEventListener('touchmove.preventDefault', preventDefault
|
|
854
|
+
el.removeEventListener(wheelEvent, preventDefault);
|
|
855
|
+
el.removeEventListener('touchmove.preventDefault', preventDefault);
|
|
867
856
|
el.removeEventListener('keydown.preventDefault', preventDefaultForScrollKeys, false);
|
|
868
857
|
|
|
869
858
|
scrollState[el] = false;
|
|
@@ -1001,7 +990,10 @@ $.fn.serializeObject = function () {
|
|
|
1001
990
|
var scrollSnapDebounce = false;
|
|
1002
991
|
Sticky.onScrollSnap = function (e)
|
|
1003
992
|
{
|
|
1004
|
-
if (Settings.debug
|
|
993
|
+
if (Settings.debug && (scrollSnap != undefined || scrollSnapStart != undefined || scrollSnapProximity != undefined)) {
|
|
994
|
+
console.log("Sticky magnetic:", scrollSnap, scrollSnapStart, scrollSnapProximity);
|
|
995
|
+
}
|
|
996
|
+
|
|
1005
997
|
if(!Settings.ready) return;
|
|
1006
998
|
|
|
1007
999
|
if(Sticky.get("passive") == true) return;
|
|
@@ -1107,7 +1099,7 @@ $.fn.serializeObject = function () {
|
|
|
1107
1099
|
Sticky.onScrollDelta = function (e) {
|
|
1108
1100
|
|
|
1109
1101
|
if (Sticky.get("disable")) return;
|
|
1110
|
-
if (Settings.debug) console.log("Sticky delta scrolling.. ", e.scrollY, e.scrollX, e.scrollT, e.screen);
|
|
1102
|
+
if (Settings.debug > 1) console.log("Sticky delta scrolling.. ", e.scrollY, e.scrollX, e.scrollT, e.screen);
|
|
1111
1103
|
if(!Settings.ready) return;
|
|
1112
1104
|
|
|
1113
1105
|
var magnets = Sticky.getMagnets(e.target);
|
|
@@ -1139,7 +1131,7 @@ $.fn.serializeObject = function () {
|
|
|
1139
1131
|
if (ids.length == 0) return;
|
|
1140
1132
|
|
|
1141
1133
|
var hash = null;
|
|
1142
|
-
if(Settings.debug) console.log("Sticky headlines:", $(ids));
|
|
1134
|
+
if(Settings.debug > 1) console.log("Sticky headlines:", $(ids));
|
|
1143
1135
|
|
|
1144
1136
|
var elAll = $(ids).filter(function() {
|
|
1145
1137
|
|
|
@@ -1501,8 +1493,8 @@ $.fn.serializeObject = function () {
|
|
|
1501
1493
|
Sticky.onAutoscroll = function() {
|
|
1502
1494
|
|
|
1503
1495
|
var container = this;
|
|
1504
|
-
var scroller = $(container)
|
|
1505
|
-
|
|
1496
|
+
var scroller = $(container).closestScrollable()[0];
|
|
1497
|
+
|
|
1506
1498
|
function parseBoolean(str) {
|
|
1507
1499
|
return /true/i.test(str);
|
|
1508
1500
|
}
|
|
@@ -1544,11 +1536,11 @@ $.fn.serializeObject = function () {
|
|
|
1544
1536
|
|
|
1545
1537
|
var _onAutoscroll = function() {
|
|
1546
1538
|
|
|
1547
|
-
var scrollHeight = $(this).prop('scrollHeight') - $(this).
|
|
1539
|
+
var scrollHeight = $(this).prop('scrollHeight') - $(this).prop("clientHeight");
|
|
1548
1540
|
var atTop = $(this).scrollTop() < 1;
|
|
1549
1541
|
var atBottom = Math.abs($(this).scrollTop() - scrollHeight) < 1;
|
|
1550
1542
|
|
|
1551
|
-
var scrollWidth = $(this).prop('scrollWidth') - $(this).
|
|
1543
|
+
var scrollWidth = $(this).prop('scrollWidth') - $(this).prop("clientWidth");
|
|
1552
1544
|
var atLeft = $(this).scrollLeft() < 1;
|
|
1553
1545
|
var atRight = Math.abs($(this).scrollLeft() - scrollWidth) < 1;
|
|
1554
1546
|
|
|
@@ -1562,6 +1554,7 @@ $.fn.serializeObject = function () {
|
|
|
1562
1554
|
|
|
1563
1555
|
if (!$(this).isScrollable()) {
|
|
1564
1556
|
if(Settings.debug) console.error(this, "is not scrollable: autoscroll canceled");
|
|
1557
|
+
return;
|
|
1565
1558
|
}
|
|
1566
1559
|
|
|
1567
1560
|
if(reverse && $(this).scrollLeft() == 0 && $(this).scrollTop() == 0)
|
|
@@ -1606,203 +1599,209 @@ $.fn.serializeObject = function () {
|
|
|
1606
1599
|
|
|
1607
1600
|
Sticky.onLoad = function (el = window)
|
|
1608
1601
|
{
|
|
1609
|
-
|
|
1602
|
+
setTimeout(() => {
|
|
1610
1603
|
|
|
1611
|
-
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1604
|
+
if(Sticky.get("disable") === true) {
|
|
1614
1605
|
|
|
1615
|
-
|
|
1606
|
+
$(".sticky").addClass("sticky-disabled");
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1616
1609
|
|
|
1617
|
-
|
|
1618
|
-
$(el).on('wheel.sticky', Sticky.onWheel);
|
|
1610
|
+
Sticky.reset(el);
|
|
1619
1611
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1612
|
+
if(Sticky.get("passive") == false)
|
|
1613
|
+
$(el).on('wheel.sticky', Sticky.onWheel);
|
|
1622
1614
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1615
|
+
$(el).on('scrolldelta.sticky', Sticky.onScrollDelta);
|
|
1616
|
+
$(el).on('scrolldelta.sticky', Sticky.debounce(Sticky.onScrollDebounce, 1000*Sticky.parseDuration(Sticky.get("debounce"))));
|
|
1625
1617
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
anchorY = anchorElem.length ? anchorElem[0].offsetTop - Sticky.getScrollPadding().top : 0;
|
|
1629
|
-
});
|
|
1618
|
+
// Sticky top anchor
|
|
1619
|
+
$(el === window ? "html" : el).find('a[href^="#"]').on('click', function () {
|
|
1630
1620
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1621
|
+
var split = this.href.split("#");
|
|
1622
|
+
var anchorElem = $(split[1] == "" ? "body" : "#"+split[1]);
|
|
1623
|
+
anchorY = anchorElem.length ? anchorElem[0].offsetTop - Sticky.getScrollPadding().top : 0;
|
|
1624
|
+
});
|
|
1633
1625
|
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
$(".sticky-swipehint-container").each(function() {
|
|
1626
|
+
if(Sticky.get("swipe"))
|
|
1627
|
+
Sticky.onSwipe($(".sticky-swipe"));
|
|
1637
1628
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1629
|
+
if(Sticky.get("swipehint"))
|
|
1630
|
+
{
|
|
1631
|
+
$(".sticky-swipehint-container").each(function() {
|
|
1640
1632
|
|
|
1641
|
-
|
|
1642
|
-
|
|
1633
|
+
var image = document.createElement("img");
|
|
1634
|
+
image.src = $(this).data("image");
|
|
1635
|
+
var span = document.createElement("span");
|
|
1636
|
+
span.append(image);
|
|
1643
1637
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1638
|
+
$(this).append(span);
|
|
1639
|
+
});
|
|
1646
1640
|
|
|
1647
|
-
|
|
1641
|
+
timeout = setTimeout(() => {
|
|
1648
1642
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1643
|
+
$(".sticky-swipehint").addClass("sticky-swipehint-reveal");
|
|
1644
|
+
$(".sticky-swipehint").on("scroll", function()
|
|
1645
|
+
{
|
|
1646
|
+
$(this).removeClass("sticky-swipehint-reveal");
|
|
1647
|
+
var debounceTime = 1000*Sticky.parseDuration(Sticky.get("swipehint_debounce"));
|
|
1648
|
+
if(!debounceTime) return;
|
|
1655
1649
|
|
|
1656
|
-
|
|
1650
|
+
$(".sticky-swipehint").on('scroll', Sticky.debounce(function() {
|
|
1657
1651
|
|
|
1658
|
-
|
|
1652
|
+
$(this).addClass("sticky-swipehint-reveal");
|
|
1659
1653
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1654
|
+
}, debounceTime));
|
|
1655
|
+
});
|
|
1662
1656
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1657
|
+
}, 1000*Sticky.parseDuration(Sticky.get("swipehint_delay") + 1));
|
|
1658
|
+
}
|
|
1665
1659
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1660
|
+
// Sticky magnet control
|
|
1661
|
+
if(Sticky.get("scrollsnap"))
|
|
1662
|
+
{
|
|
1663
|
+
$(".sticky-magnet-first").on("click", function() { Sticky.scrollToFirstSnap(); });
|
|
1664
|
+
$(".sticky-magnet-prev" ).on("click", function() { Sticky.scrollToPreviousSnap(); });
|
|
1665
|
+
$(".sticky-magnet-next" ).on("click", function() { Sticky.scrollToNextSnap(); });
|
|
1666
|
+
$(".sticky-magnet-last" ).on("click", function() { Sticky.scrollToLastSnap(); });
|
|
1673
1667
|
|
|
1674
|
-
|
|
1675
|
-
|
|
1668
|
+
$(el).on('scrolldelta.sticky.snap', Sticky.onScrollSnap);
|
|
1669
|
+
}
|
|
1676
1670
|
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1671
|
+
// Sticky percent scroll
|
|
1672
|
+
if(Sticky.get("scrollpercent"))
|
|
1673
|
+
{
|
|
1674
|
+
$(el).on('scrolldelta.sticky.percent', Sticky.onScrollPercent);
|
|
1675
|
+
$(".sticky-scrollpercent").each(function() {
|
|
1676
|
+
if(el == this) return;
|
|
1677
|
+
$(this).on('scrolldelta.sticky.percent', Sticky.onScrollPercent);
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
// Sticky autoscroll
|
|
1682
|
+
if(Sticky.get("autoscroll"))
|
|
1686
1683
|
|
|
1687
|
-
|
|
1688
|
-
if(Sticky.get("autoscroll"))
|
|
1684
|
+
$(".sticky-autoscroll").each(function() {
|
|
1689
1685
|
|
|
1690
|
-
|
|
1686
|
+
var container = this;
|
|
1687
|
+
var scroller = $(container);
|
|
1691
1688
|
|
|
1692
|
-
|
|
1693
|
-
|
|
1689
|
+
var reverseDelay = $(scroller).data("autoscroll-delay-reverse");
|
|
1690
|
+
if (reverseDelay == undefined) reverseDelay = Sticky.get("autoscroll_delay_reverse");
|
|
1691
|
+
var reverseSpeed = $(scroller).data("autoscroll-speed-reverse");
|
|
1692
|
+
if (reverseSpeed == undefined) reverseSpeed = Sticky.get("autoscroll_speed_reverse");
|
|
1693
|
+
var reverseDuration = $(scroller).data("autoscroll-duration-reverse");
|
|
1694
|
+
if (reverseDuration == undefined) reverseDuration = Sticky.get("autoscroll_duration_reverse");
|
|
1694
1695
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
var reverseSpeed = $(scroller).data("autoscroll-speed-reverse");
|
|
1698
|
-
if (reverseSpeed == undefined) reverseSpeed = Sticky.get("autoscroll_speed_reverse");
|
|
1699
|
-
var reverseDuration = $(scroller).data("autoscroll-duration-reverse");
|
|
1700
|
-
if (reverseDuration == undefined) reverseDuration = Sticky.get("autoscroll_duration_reverse");
|
|
1696
|
+
var startOver = $(scroller).data("autoscroll-startover");
|
|
1697
|
+
if (startOver == undefined) startOver = Sticky.get("autoscroll_startover");
|
|
1701
1698
|
|
|
1702
|
-
|
|
1703
|
-
|
|
1699
|
+
var delay = $(scroller).data("autoscroll-delay");
|
|
1700
|
+
if (delay == undefined) delay = Sticky.get("autoscroll_delay");
|
|
1704
1701
|
|
|
1705
|
-
|
|
1706
|
-
|
|
1702
|
+
var thresholdMinX = $(scroller).data("autoscroll-minwidth");
|
|
1703
|
+
if(thresholdMinX == undefined) thresholdMinX = Sticky.get("autoscroll_minwidth");
|
|
1704
|
+
var thresholdMinY = $(scroller).data("autoscroll-minheight");
|
|
1705
|
+
if(thresholdMinY == undefined) thresholdMinY = Sticky.get("autoscroll_minheight");
|
|
1707
1706
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
if(thresholdMinY == undefined) thresholdMinY = Sticky.get("autoscroll_minheight");
|
|
1707
|
+
var scrollHeight = $(scroller).prop('scrollHeight') - $(scroller).prop("clientHeight");
|
|
1708
|
+
var atTop = $(scroller).scrollTop() < 1;
|
|
1709
|
+
var atBottom = Math.abs($(scroller).scrollTop() - scrollHeight) < 1;
|
|
1712
1710
|
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1711
|
+
var scrollWidth = $(scroller).prop('scrollWidth') - $(scroller).prop("clientWidth");
|
|
1712
|
+
var atLeft = $(scroller).scrollLeft() < 1;
|
|
1713
|
+
var atRight = Math.abs($(scroller).scrollLeft() - scrollWidth) < 1;
|
|
1716
1714
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
var atRight = Math.abs($(scroller).scrollLeft() - scrollWidth) < 1;
|
|
1715
|
+
var mouseAction = $(scroller).data("autoscroll-mouse-action");
|
|
1716
|
+
if (mouseAction == undefined) mouseAction = Sticky.get("autoscroll_mouse_action");
|
|
1720
1717
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1718
|
+
var noScrollY = (atTop && atBottom) || scrollHeight < thresholdMinY;
|
|
1719
|
+
var noScrollX = (atLeft && atRight) || scrollWidth < thresholdMinX;
|
|
1723
1720
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1721
|
+
$(scroller).data("autoscroll-prevent", false);
|
|
1722
|
+
$(scroller).off("wheel.autoscroll DOMMouseScroll.autoscroll mousewheel.autoscroll touchstart.autoscroll");
|
|
1723
|
+
$(scroller).on("wheel.autoscroll DOMMouseScroll.autoscroll mousewheel.autoscroll touchstart.autoscroll", function(e) {
|
|
1726
1724
|
|
|
1727
|
-
|
|
1725
|
+
$(this).prop("user-scroll", true);
|
|
1726
|
+
$(this).stop();
|
|
1727
|
+
});
|
|
1728
1728
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1729
|
+
var autoscrollTimeout = undefined;
|
|
1730
|
+
var payloadAutoscroll = function() {
|
|
1731
1731
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1732
|
+
if(autoscrollTimeout != undefined) clearTimeout(autoscrollTimeout);
|
|
1733
|
+
autoscrollTimeout = setTimeout(() => Sticky.onAutoscroll.call(container), 1000*Sticky.parseDuration(delay) + 1);
|
|
1734
|
+
};
|
|
1735
1735
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1736
|
+
//
|
|
1737
|
+
// Mouse events
|
|
1738
|
+
if (mouseAction) {
|
|
1739
1739
|
|
|
1740
|
-
|
|
1741
|
-
|
|
1740
|
+
$(scroller).off("mousewheel.autoscroll mouseenter.autoscroll touchstart.autoscroll");
|
|
1741
|
+
$(scroller).on("mousewheel.autoscroll mouseenter.autoscroll touchstart.autoscroll", function() {
|
|
1742
1742
|
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1743
|
+
if(autoscrollTimeout != undefined) clearTimeout(autoscrollTimeout);
|
|
1744
|
+
$(scroller).prop("user-scroll", true);
|
|
1745
|
+
$(scroller).stop();
|
|
1746
|
+
});
|
|
1747
1747
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1748
|
+
$(scroller).on("mouseleave.autoscroll touchend.autoscroll");
|
|
1749
|
+
$(scroller).on("mouseleave.autoscroll touchend.autoscroll", function() {
|
|
1750
1750
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1751
|
+
if(startOver) payloadAutoscroll();
|
|
1752
|
+
else {
|
|
1753
1753
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1754
|
+
$(scroller).data("autoscroll-prevent", "true");
|
|
1755
|
+
$(scroller).off("mouseleave.autoscroll touchend.autoscroll");
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1758
1759
|
|
|
1759
|
-
|
|
1760
|
-
$(scroller).on("
|
|
1760
|
+
// Disable on user scroll before unloading
|
|
1761
|
+
$(scroller).on("beforeunload.autoscroll");
|
|
1762
|
+
$(scroller).on("beforeunload.autoscroll", function() {
|
|
1761
1763
|
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1764
|
+
if (mouseAction) {
|
|
1765
|
+
$(this).off("mousewheel.autoscroll touchstart.autoscroll");
|
|
1766
|
+
$(this).off("mouseenter.autoscroll touchstart.autoscroll");
|
|
1767
|
+
$(this).off("mouseleave.autoscroll touchend.autoscroll");
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1765
1770
|
$(this).off("scroll.autoscroll");
|
|
1766
|
-
$(this).off("
|
|
1771
|
+
$(this).off("beforeunload.autoscroll");
|
|
1767
1772
|
|
|
1768
1773
|
var scrollerWindow = $(this).closestScrollableWindow();
|
|
1769
1774
|
$(scrollerWindow).off("scroll.autoscroll");
|
|
1770
1775
|
});
|
|
1771
|
-
}
|
|
1772
1776
|
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
+
//
|
|
1778
|
+
// Call action
|
|
1779
|
+
if(noScrollY && noScrollX) payloadAutoscroll();
|
|
1780
|
+
else if($(scroller).data("autoscroll-reverse")) {
|
|
1777
1781
|
|
|
1778
|
-
|
|
1779
|
-
|
|
1782
|
+
var scrollWidth = $(scroller).prop('scrollWidth') - scroller.prop("clientWidth");
|
|
1783
|
+
var scrollHeight = $(scroller).prop('scrollHeight') - scroller.prop("clientHeight");
|
|
1780
1784
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1785
|
+
if (Settings.debug) console.log("Autoscroll reverse delay applied is \"" + reverseDelay + "\".");
|
|
1786
|
+
setTimeout(() => Sticky.scrollTo({
|
|
1787
|
+
left:scrollWidth,
|
|
1788
|
+
top:scrollHeight,
|
|
1789
|
+
duration:reverseDuration,
|
|
1790
|
+
speed:reverseSpeed
|
|
1791
|
+
}, payloadAutoscroll, scroller), 1000*Sticky.parseDuration(reverseDelay + 1));
|
|
1783
1792
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1793
|
+
} else payloadAutoscroll();
|
|
1794
|
+
}
|
|
1795
|
+
);
|
|
1787
1796
|
|
|
1788
|
-
|
|
1789
|
-
setTimeout(() => Sticky.scrollTo({
|
|
1790
|
-
left:scrollWidth,
|
|
1791
|
-
top:scrollHeight,
|
|
1792
|
-
duration:reverseDuration,
|
|
1793
|
-
speed:reverseSpeed
|
|
1794
|
-
}, payloadAutoscroll, scroller), 1000*Sticky.parseDuration(reverseDelay + 1));
|
|
1797
|
+
Settings.ready = true;
|
|
1795
1798
|
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
);
|
|
1799
|
-
|
|
1800
|
-
Settings.ready = true;
|
|
1799
|
+
}, 1);
|
|
1801
1800
|
|
|
1802
1801
|
return this;
|
|
1803
1802
|
}
|
|
1804
1803
|
|
|
1805
|
-
$(window).on("
|
|
1804
|
+
$(window).on("beforeunload", function() {
|
|
1806
1805
|
|
|
1807
1806
|
Settings.ready = false;
|
|
1808
1807
|
Sticky.reset();
|