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

Function getTween

esm/ScrollTrigger.js:871–906  ·  view source on GitHub ↗
(scrollTo, vars, initialValue, change1, change2)

Source from the content-addressed store, hash-verified

869 prop = "_scroll" + direction.p2,
870 // add a tweenable property to the scroller that's a getter/setter function, like _scrollTop or _scrollLeft. This way, if someone does gsap.killTweensOf(scroller) it'll kill the scroll tween.
871 getTween = function getTween(scrollTo, vars, initialValue, change1, change2) {
872 var tween = getTween.tween,
873 onComplete = vars.onComplete,
874 modifiers = {};
875 initialValue = initialValue || getScroll();
876
877 var checkForInterruption = _interruptionTracker(getScroll, initialValue, function () {
878 tween.kill();
879 getTween.tween = 0;
880 });
881
882 change2 = change1 && change2 || 0; // if change1 is 0, we set that to the difference and ignore change2. Otherwise, there would be a compound effect.
883
884 change1 = change1 || scrollTo - initialValue;
885 tween && tween.kill();
886 vars[prop] = scrollTo;
887 vars.inherit = false;
888 vars.modifiers = modifiers;
889
890 modifiers[prop] = function () {
891 return checkForInterruption(initialValue + change1 * tween.ratio + change2 * tween.ratio * tween.ratio);
892 };
893
894 vars.onUpdate = function () {
895 _scrollers.cache++;
896 getTween.tween && _updateAll(); // if it was interrupted/killed, like in a context.revert(), don't force an updateAll()
897 };
898
899 vars.onComplete = function () {
900 getTween.tween = 0;
901 onComplete && onComplete.call(tween);
902 };
903
904 tween = getTween.tween = gsap.to(scroller, vars);
905 return tween;
906 };
907
908 scroller[prop] = getScroll;
909

Callers

nothing calls this directly

Calls 5

callMethod · 0.80
_interruptionTrackerFunction · 0.70
_updateAllFunction · 0.70
killMethod · 0.65
toMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…