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

Function interpolate

esm/gsap-core.js:888–945  ·  view source on GitHub ↗
(start, end, progress, mutate)

Source from the content-addressed store, hash-verified

886 });
887},
888 interpolate = function interpolate(start, end, progress, mutate) {
889 var func = isNaN(start + end) ? 0 : function (p) {
890 return (1 - p) * start + p * end;
891 };
892
893 if (!func) {
894 var isString = _isString(start),
895 master = {},
896 p,
897 i,
898 interpolators,
899 l,
900 il;
901
902 progress === true && (mutate = 1) && (progress = null);
903
904 if (isString) {
905 start = {
906 p: start
907 };
908 end = {
909 p: end
910 };
911 } else if (_isArray(start) && !_isArray(end)) {
912 interpolators = [];
913 l = start.length;
914 il = l - 2;
915
916 for (i = 1; i < l; i++) {
917 interpolators.push(interpolate(start[i - 1], start[i])); //build the interpolators up front as a performance optimization so that when the function is called many times, it can just reuse them.
918 }
919
920 l--;
921
922 func = function func(p) {
923 p *= l;
924 var i = Math.min(il, ~~p);
925 return interpolators[i](p - i);
926 };
927
928 progress = end;
929 } else if (!mutate) {
930 start = _merge(_isArray(start) ? [] : {}, start);
931 }
932
933 if (!interpolators) {
934 for (p in end) {
935 _addPropTween.call(master, start, p, "get", end[p]);
936 }
937
938 func = function func(p) {
939 return _renderPropTweens(p, master) || (isString ? start.p : start);
940 };
941 }
942 }
943
944 return _conditionalReturn(progress, func);
945},

Callers

nothing calls this directly

Calls 5

callMethod · 0.80
_isStringFunction · 0.70
_mergeFunction · 0.70
_renderPropTweensFunction · 0.70
_conditionalReturnFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…