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

Function ScrollSmoother

esm/ScrollSmoother.js:86–951  ·  view source on GitHub ↗
(vars)

Source from the content-addressed store, hash-verified

84
85export var ScrollSmoother = /*#__PURE__*/function () {
86 function ScrollSmoother(vars) {
87 var _this = this;
88
89 _coreInitted || ScrollSmoother.register(gsap) || console.warn("Please gsap.registerPlugin(ScrollSmoother)");
90 vars = this.vars = vars || {};
91 _mainInstance && _mainInstance.kill();
92 _mainInstance = this;
93
94 _context(this);
95
96 var _vars = vars,
97 smoothTouch = _vars.smoothTouch,
98 _onUpdate = _vars.onUpdate,
99 onStop = _vars.onStop,
100 smooth = _vars.smooth,
101 onFocusIn = _vars.onFocusIn,
102 normalizeScroll = _vars.normalizeScroll,
103 wholePixels = _vars.wholePixels,
104 content,
105 wrapper,
106 height,
107 mainST,
108 effects,
109 sections,
110 intervalID,
111 wrapperCSS,
112 contentCSS,
113 paused,
114 pausedNormalizer,
115 recordedRefreshScroll,
116 recordedRefreshScrub,
117 allowUpdates,
118 self = this,
119 effectsPrefix = vars.effectsPrefix || "",
120 scrollFunc = ScrollTrigger.getScrollFunc(_win),
121 smoothDuration = ScrollTrigger.isTouch === 1 ? smoothTouch === true ? 0.8 : parseFloat(smoothTouch) || 0 : smooth === 0 || smooth === false ? 0 : parseFloat(smooth) || 0.8,
122 speed = smoothDuration && +vars.speed || 1,
123 currentY = 0,
124 delta = 0,
125 startupPhase = 1,
126 tracker = _getVelocityProp(0),
127 updateVelocity = function updateVelocity() {
128 return tracker.update(-currentY);
129 },
130 scroll = {
131 y: 0
132 },
133 removeScroll = function removeScroll() {
134 return content.style.overflow = "visible";
135 },
136 isProxyScrolling,
137 killScrub = function killScrub(trigger) {
138 trigger.update(); // it's possible that it hasn't been synchronized with the actual scroll position yet, like if it's later in the _triggers Array. If it was already updated, it'll skip the processing anyway.
139
140 var scrub = trigger.getTween();
141
142 if (scrub) {
143 scrub.pause();

Callers

nothing calls this directly

Calls 15

scrollTopFunction · 0.85
addOnRefreshFunction · 0.85
adjustParallaxPositionFunction · 0.85
refreshHeightFunction · 0.85
createEffectFunction · 0.85
killScrubFunction · 0.85
updateVelocityFunction · 0.85
restartMethod · 0.80
addEventListenerMethod · 0.80
delayedCallMethod · 0.80
applyMethod · 0.80
scrollerProxyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…