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

Function _getScrollNormalizer

esm/ScrollTrigger.js:2423–2643  ·  view source on GitHub ↗
(vars)

Source from the content-addressed store, hash-verified

2421 }
2422},
2423 _getScrollNormalizer = function _getScrollNormalizer(vars) {
2424 _isObject(vars) || (vars = {});
2425 vars.preventDefault = vars.isNormalizer = vars.allowClicks = true;
2426 vars.type || (vars.type = "wheel,touch");
2427 vars.debounce = !!vars.debounce;
2428 vars.id = vars.id || "normalizer";
2429
2430 var _vars2 = vars,
2431 normalizeScrollX = _vars2.normalizeScrollX,
2432 momentum = _vars2.momentum,
2433 allowNestedScroll = _vars2.allowNestedScroll,
2434 onRelease = _vars2.onRelease,
2435 self,
2436 maxY,
2437 target = _getTarget(vars.target) || _docEl,
2438 smoother = gsap.core.globals().ScrollSmoother,
2439 smootherInstance = smoother && smoother.get(),
2440 content = _fixIOSBug && (vars.content && _getTarget(vars.content) || smootherInstance && vars.content !== false && !smootherInstance.smooth() && smootherInstance.content()),
2441 scrollFuncY = _getScrollFunc(target, _vertical),
2442 scrollFuncX = _getScrollFunc(target, _horizontal),
2443 scale = 1,
2444 initialScale = (Observer.isTouch && _win.visualViewport ? _win.visualViewport.scale * _win.visualViewport.width : _win.outerWidth) / _win.innerWidth,
2445 wheelRefresh = 0,
2446 resolveMomentumDuration = _isFunction(momentum) ? function () {
2447 return momentum(self);
2448 } : function () {
2449 return momentum || 2.8;
2450 },
2451 lastRefreshID,
2452 skipTouchMove,
2453 inputObserver = _inputObserver(target, vars.type, true, allowNestedScroll),
2454 resumeTouchMove = function resumeTouchMove() {
2455 return skipTouchMove = false;
2456 },
2457 scrollClampX = _passThrough,
2458 scrollClampY = _passThrough,
2459 updateClamps = function updateClamps() {
2460 maxY = _maxScroll(target, _vertical);
2461 scrollClampY = _clamp(_fixIOSBug ? 1 : 0, maxY);
2462 normalizeScrollX && (scrollClampX = _clamp(0, _maxScroll(target, _horizontal)));
2463 lastRefreshID = _refreshID;
2464 },
2465 removeContentOffset = function removeContentOffset() {
2466 content._gsap.y = _round(parseFloat(content._gsap.y) + scrollFuncY.offset) + "px";
2467 content.style.transform = "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, " + parseFloat(content._gsap.y) + ", 0, 1)";
2468 scrollFuncY.offset = scrollFuncY.cacheID = 0;
2469 },
2470 ignoreDrag = function ignoreDrag() {
2471 if (skipTouchMove) {
2472 requestAnimationFrame(resumeTouchMove);
2473
2474 var offset = _round(self.deltaY / 2),
2475 scroll = scrollClampY(scrollFuncY.v - offset);
2476
2477 if (content && scroll !== scrollFuncY.v + scrollFuncY.offset) {
2478 scrollFuncY.offset = scroll - scrollFuncY.v;
2479
2480 var y = _round((parseFloat(content && content._gsap.y) || 0) - scrollFuncY.offset);

Callers 1

ScrollTrigger.jsFile · 0.70

Calls 15

_getTargetFunction · 0.90
_getScrollFuncFunction · 0.90
onReleaseFunction · 0.85
pauseMethod · 0.80
restartMethod · 0.80
playMethod · 0.80
durationMethod · 0.80
addEventListenerMethod · 0.80
enableMethod · 0.80
removeEventListenerMethod · 0.80
_isObjectFunction · 0.70
_isFunctionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…