MCPcopy
hub / github.com/greensock/GSAP / _interruptionTracker

Function _interruptionTracker

esm/ScrollTrigger.js:838–854  ·  view source on GitHub ↗
(getValueFunc, initialValue, onInterrupt)

Source from the content-addressed store, hash-verified

836 }
837},
838 _interruptionTracker = function _interruptionTracker(getValueFunc, initialValue, onInterrupt) {
839 var last1 = initialValue,
840 last2 = last1;
841 return function (value) {
842 var current = Math.round(getValueFunc()); // round because in some [very uncommon] Windows environments, scroll can get reported with decimals even though it was set without.
843
844 if (current !== last1 && current !== last2 && Math.abs(current - last1) > 3 && Math.abs(current - last2) > 3) {
845 // if the user scrolls, kill the tween. iOS Safari intermittently misreports the scroll position, it may be the most recently-set one or the one before that! When Safari is zoomed (CMD-+), it often misreports as 1 pixel off too! So if we set the scroll position to 125, for example, it'll actually report it as 124.
846 value = current;
847 onInterrupt && onInterrupt();
848 }
849
850 last2 = last1;
851 last1 = Math.round(value);
852 return last1;
853 };
854},
855 _shiftMarker = function _shiftMarker(marker, direction, value) {
856 var vars = {};
857 vars[direction.p] = "+=" + value;

Callers 2

getTweenFunction · 0.70
_getScrollNormalizerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…