Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
return this.payload.map(function (v) {
[46500] Fix | Delete
return v.getValue();
[46501] Fix | Delete
});
[46502] Fix | Delete
};
[46503] Fix | Delete
[46504] Fix | Delete
_proto.interpolate = function interpolate(range, output) {
[46505] Fix | Delete
return new AnimatedInterpolation(this, range, output);
[46506] Fix | Delete
};
[46507] Fix | Delete
[46508] Fix | Delete
return AnimatedValueArray;
[46509] Fix | Delete
}(AnimatedArray);
[46510] Fix | Delete
[46511] Fix | Delete
var G = 0;
[46512] Fix | Delete
[46513] Fix | Delete
var Controller =
[46514] Fix | Delete
/*#__PURE__*/
[46515] Fix | Delete
function () {
[46516] Fix | Delete
function Controller() {
[46517] Fix | Delete
var _this = this;
[46518] Fix | Delete
[46519] Fix | Delete
this.id = void 0;
[46520] Fix | Delete
this.idle = true;
[46521] Fix | Delete
this.hasChanged = false;
[46522] Fix | Delete
this.guid = 0;
[46523] Fix | Delete
this.local = 0;
[46524] Fix | Delete
this.props = {};
[46525] Fix | Delete
this.merged = {};
[46526] Fix | Delete
this.animations = {};
[46527] Fix | Delete
this.interpolations = {};
[46528] Fix | Delete
this.values = {};
[46529] Fix | Delete
this.configs = [];
[46530] Fix | Delete
this.listeners = [];
[46531] Fix | Delete
this.queue = [];
[46532] Fix | Delete
this.localQueue = void 0;
[46533] Fix | Delete
[46534] Fix | Delete
this.getValues = function () {
[46535] Fix | Delete
return _this.interpolations;
[46536] Fix | Delete
};
[46537] Fix | Delete
[46538] Fix | Delete
this.id = G++;
[46539] Fix | Delete
}
[46540] Fix | Delete
/** update(props)
[46541] Fix | Delete
* This function filters input props and creates an array of tasks which are executed in .start()
[46542] Fix | Delete
* Each task is allowed to carry a delay, which means it can execute asnychroneously */
[46543] Fix | Delete
[46544] Fix | Delete
[46545] Fix | Delete
var _proto = Controller.prototype;
[46546] Fix | Delete
[46547] Fix | Delete
_proto.update = function update$$1(args) {
[46548] Fix | Delete
//this._id = n + this.id
[46549] Fix | Delete
if (!args) return this; // Extract delay and the to-prop from props
[46550] Fix | Delete
[46551] Fix | Delete
var _ref = interpolateTo(args),
[46552] Fix | Delete
_ref$delay = _ref.delay,
[46553] Fix | Delete
delay = _ref$delay === void 0 ? 0 : _ref$delay,
[46554] Fix | Delete
to = _ref.to,
[46555] Fix | Delete
props = _objectWithoutPropertiesLoose(_ref, ["delay", "to"]);
[46556] Fix | Delete
[46557] Fix | Delete
if (is.arr(to) || is.fun(to)) {
[46558] Fix | Delete
// If config is either a function or an array queue it up as is
[46559] Fix | Delete
this.queue.push(_extends({}, props, {
[46560] Fix | Delete
delay: delay,
[46561] Fix | Delete
to: to
[46562] Fix | Delete
}));
[46563] Fix | Delete
} else if (to) {
[46564] Fix | Delete
// Otherwise go through each key since it could be delayed individually
[46565] Fix | Delete
var ops = {};
[46566] Fix | Delete
Object.entries(to).forEach(function (_ref2) {
[46567] Fix | Delete
var _to;
[46568] Fix | Delete
[46569] Fix | Delete
var k = _ref2[0],
[46570] Fix | Delete
v = _ref2[1];
[46571] Fix | Delete
[46572] Fix | Delete
// Fetch delay and create an entry, consisting of the to-props, the delay, and basic props
[46573] Fix | Delete
var entry = _extends({
[46574] Fix | Delete
to: (_to = {}, _to[k] = v, _to),
[46575] Fix | Delete
delay: callProp(delay, k)
[46576] Fix | Delete
}, props);
[46577] Fix | Delete
[46578] Fix | Delete
var previous = ops[entry.delay] && ops[entry.delay].to;
[46579] Fix | Delete
ops[entry.delay] = _extends({}, ops[entry.delay], entry, {
[46580] Fix | Delete
to: _extends({}, previous, entry.to)
[46581] Fix | Delete
});
[46582] Fix | Delete
});
[46583] Fix | Delete
this.queue = Object.values(ops);
[46584] Fix | Delete
} // Sort queue, so that async calls go last
[46585] Fix | Delete
[46586] Fix | Delete
[46587] Fix | Delete
this.queue = this.queue.sort(function (a, b) {
[46588] Fix | Delete
return a.delay - b.delay;
[46589] Fix | Delete
}); // Diff the reduced props immediately (they'll contain the from-prop and some config)
[46590] Fix | Delete
[46591] Fix | Delete
this.diff(props);
[46592] Fix | Delete
return this;
[46593] Fix | Delete
}
[46594] Fix | Delete
/** start(onEnd)
[46595] Fix | Delete
* This function either executes a queue, if present, or starts the frameloop, which animates */
[46596] Fix | Delete
;
[46597] Fix | Delete
[46598] Fix | Delete
_proto.start = function start$$1(onEnd) {
[46599] Fix | Delete
var _this2 = this;
[46600] Fix | Delete
[46601] Fix | Delete
// If a queue is present we must excecute it
[46602] Fix | Delete
if (this.queue.length) {
[46603] Fix | Delete
this.idle = false; // Updates can interrupt trailing queues, in that case we just merge values
[46604] Fix | Delete
[46605] Fix | Delete
if (this.localQueue) {
[46606] Fix | Delete
this.localQueue.forEach(function (_ref3) {
[46607] Fix | Delete
var _ref3$from = _ref3.from,
[46608] Fix | Delete
from = _ref3$from === void 0 ? {} : _ref3$from,
[46609] Fix | Delete
_ref3$to = _ref3.to,
[46610] Fix | Delete
to = _ref3$to === void 0 ? {} : _ref3$to;
[46611] Fix | Delete
if (is.obj(from)) _this2.merged = _extends({}, from, _this2.merged);
[46612] Fix | Delete
if (is.obj(to)) _this2.merged = _extends({}, _this2.merged, to);
[46613] Fix | Delete
});
[46614] Fix | Delete
} // The guid helps us tracking frames, a new queue over an old one means an override
[46615] Fix | Delete
// We discard async calls in that caseÍ
[46616] Fix | Delete
[46617] Fix | Delete
[46618] Fix | Delete
var local = this.local = ++this.guid;
[46619] Fix | Delete
var queue = this.localQueue = this.queue;
[46620] Fix | Delete
this.queue = []; // Go through each entry and execute it
[46621] Fix | Delete
[46622] Fix | Delete
queue.forEach(function (_ref4, index) {
[46623] Fix | Delete
var delay = _ref4.delay,
[46624] Fix | Delete
props = _objectWithoutPropertiesLoose(_ref4, ["delay"]);
[46625] Fix | Delete
[46626] Fix | Delete
var cb = function cb(finished) {
[46627] Fix | Delete
if (index === queue.length - 1 && local === _this2.guid && finished) {
[46628] Fix | Delete
_this2.idle = true;
[46629] Fix | Delete
if (_this2.props.onRest) _this2.props.onRest(_this2.merged);
[46630] Fix | Delete
}
[46631] Fix | Delete
[46632] Fix | Delete
if (onEnd) onEnd();
[46633] Fix | Delete
}; // Entries can be delayed, ansyc or immediate
[46634] Fix | Delete
[46635] Fix | Delete
[46636] Fix | Delete
var async = is.arr(props.to) || is.fun(props.to);
[46637] Fix | Delete
[46638] Fix | Delete
if (delay) {
[46639] Fix | Delete
setTimeout(function () {
[46640] Fix | Delete
if (local === _this2.guid) {
[46641] Fix | Delete
if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
[46642] Fix | Delete
}
[46643] Fix | Delete
}, delay);
[46644] Fix | Delete
} else if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
[46645] Fix | Delete
});
[46646] Fix | Delete
} // Otherwise we kick of the frameloop
[46647] Fix | Delete
else {
[46648] Fix | Delete
if (is.fun(onEnd)) this.listeners.push(onEnd);
[46649] Fix | Delete
if (this.props.onStart) this.props.onStart();
[46650] Fix | Delete
[46651] Fix | Delete
start(this);
[46652] Fix | Delete
}
[46653] Fix | Delete
[46654] Fix | Delete
return this;
[46655] Fix | Delete
};
[46656] Fix | Delete
[46657] Fix | Delete
_proto.stop = function stop$$1(finished) {
[46658] Fix | Delete
this.listeners.forEach(function (onEnd) {
[46659] Fix | Delete
return onEnd(finished);
[46660] Fix | Delete
});
[46661] Fix | Delete
this.listeners = [];
[46662] Fix | Delete
return this;
[46663] Fix | Delete
}
[46664] Fix | Delete
/** Pause sets onEnd listeners free, but also removes the controller from the frameloop */
[46665] Fix | Delete
;
[46666] Fix | Delete
[46667] Fix | Delete
_proto.pause = function pause(finished) {
[46668] Fix | Delete
this.stop(true);
[46669] Fix | Delete
if (finished) stop(this);
[46670] Fix | Delete
return this;
[46671] Fix | Delete
};
[46672] Fix | Delete
[46673] Fix | Delete
_proto.runAsync = function runAsync(_ref5, onEnd) {
[46674] Fix | Delete
var _this3 = this;
[46675] Fix | Delete
[46676] Fix | Delete
var delay = _ref5.delay,
[46677] Fix | Delete
props = _objectWithoutPropertiesLoose(_ref5, ["delay"]);
[46678] Fix | Delete
[46679] Fix | Delete
var local = this.local; // If "to" is either a function or an array it will be processed async, therefor "to" should be empty right now
[46680] Fix | Delete
// If the view relies on certain values "from" has to be present
[46681] Fix | Delete
[46682] Fix | Delete
var queue = Promise.resolve(undefined);
[46683] Fix | Delete
[46684] Fix | Delete
if (is.arr(props.to)) {
[46685] Fix | Delete
var _loop = function _loop(i) {
[46686] Fix | Delete
var index = i;
[46687] Fix | Delete
[46688] Fix | Delete
var fresh = _extends({}, props, interpolateTo(props.to[index]));
[46689] Fix | Delete
[46690] Fix | Delete
if (is.arr(fresh.config)) fresh.config = fresh.config[index];
[46691] Fix | Delete
queue = queue.then(function () {
[46692] Fix | Delete
//this.stop()
[46693] Fix | Delete
if (local === _this3.guid) return new Promise(function (r) {
[46694] Fix | Delete
return _this3.diff(fresh).start(r);
[46695] Fix | Delete
});
[46696] Fix | Delete
});
[46697] Fix | Delete
};
[46698] Fix | Delete
[46699] Fix | Delete
for (var i = 0; i < props.to.length; i++) {
[46700] Fix | Delete
_loop(i);
[46701] Fix | Delete
}
[46702] Fix | Delete
} else if (is.fun(props.to)) {
[46703] Fix | Delete
var index = 0;
[46704] Fix | Delete
var last;
[46705] Fix | Delete
queue = queue.then(function () {
[46706] Fix | Delete
return props.to( // next(props)
[46707] Fix | Delete
function (p) {
[46708] Fix | Delete
var fresh = _extends({}, props, interpolateTo(p));
[46709] Fix | Delete
[46710] Fix | Delete
if (is.arr(fresh.config)) fresh.config = fresh.config[index];
[46711] Fix | Delete
index++; //this.stop()
[46712] Fix | Delete
[46713] Fix | Delete
if (local === _this3.guid) return last = new Promise(function (r) {
[46714] Fix | Delete
return _this3.diff(fresh).start(r);
[46715] Fix | Delete
});
[46716] Fix | Delete
return;
[46717] Fix | Delete
}, // cancel()
[46718] Fix | Delete
function (finished) {
[46719] Fix | Delete
if (finished === void 0) {
[46720] Fix | Delete
finished = true;
[46721] Fix | Delete
}
[46722] Fix | Delete
[46723] Fix | Delete
return _this3.stop(finished);
[46724] Fix | Delete
}).then(function () {
[46725] Fix | Delete
return last;
[46726] Fix | Delete
});
[46727] Fix | Delete
});
[46728] Fix | Delete
}
[46729] Fix | Delete
[46730] Fix | Delete
queue.then(onEnd);
[46731] Fix | Delete
};
[46732] Fix | Delete
[46733] Fix | Delete
_proto.diff = function diff(props) {
[46734] Fix | Delete
var _this4 = this;
[46735] Fix | Delete
[46736] Fix | Delete
this.props = _extends({}, this.props, props);
[46737] Fix | Delete
var _this$props = this.props,
[46738] Fix | Delete
_this$props$from = _this$props.from,
[46739] Fix | Delete
from = _this$props$from === void 0 ? {} : _this$props$from,
[46740] Fix | Delete
_this$props$to = _this$props.to,
[46741] Fix | Delete
to = _this$props$to === void 0 ? {} : _this$props$to,
[46742] Fix | Delete
_this$props$config = _this$props.config,
[46743] Fix | Delete
config = _this$props$config === void 0 ? {} : _this$props$config,
[46744] Fix | Delete
reverse = _this$props.reverse,
[46745] Fix | Delete
attach = _this$props.attach,
[46746] Fix | Delete
reset = _this$props.reset,
[46747] Fix | Delete
immediate = _this$props.immediate; // Reverse values when requested
[46748] Fix | Delete
[46749] Fix | Delete
if (reverse) {
[46750] Fix | Delete
var _ref6 = [to, from];
[46751] Fix | Delete
from = _ref6[0];
[46752] Fix | Delete
to = _ref6[1];
[46753] Fix | Delete
} // This will collect all props that were ever set, reset merged props when necessary
[46754] Fix | Delete
[46755] Fix | Delete
[46756] Fix | Delete
this.merged = _extends({}, from, this.merged, to);
[46757] Fix | Delete
this.hasChanged = false; // Attachment handling, trailed springs can "attach" themselves to a previous spring
[46758] Fix | Delete
[46759] Fix | Delete
var target = attach && attach(this); // Reduces input { name: value } pairs into animated values
[46760] Fix | Delete
[46761] Fix | Delete
this.animations = Object.entries(this.merged).reduce(function (acc, _ref7) {
[46762] Fix | Delete
var name = _ref7[0],
[46763] Fix | Delete
value = _ref7[1];
[46764] Fix | Delete
// Issue cached entries, except on reset
[46765] Fix | Delete
var entry = acc[name] || {}; // Figure out what the value is supposed to be
[46766] Fix | Delete
[46767] Fix | Delete
var isNumber = is.num(value);
[46768] Fix | Delete
var isString = is.str(value) && !value.startsWith('#') && !/\d/.test(value) && !colorNames[value];
[46769] Fix | Delete
var isArray = is.arr(value);
[46770] Fix | Delete
var isInterpolation = !isNumber && !isArray && !isString;
[46771] Fix | Delete
var fromValue = !is.und(from[name]) ? from[name] : value;
[46772] Fix | Delete
var toValue = isNumber || isArray ? value : isString ? value : 1;
[46773] Fix | Delete
var toConfig = callProp(config, name);
[46774] Fix | Delete
if (target) toValue = target.animations[name].parent;
[46775] Fix | Delete
var parent = entry.parent,
[46776] Fix | Delete
interpolation$$1 = entry.interpolation,
[46777] Fix | Delete
toValues = toArray(target ? toValue.getPayload() : toValue),
[46778] Fix | Delete
animatedValues;
[46779] Fix | Delete
var newValue = value;
[46780] Fix | Delete
if (isInterpolation) newValue = interpolation({
[46781] Fix | Delete
range: [0, 1],
[46782] Fix | Delete
output: [value, value]
[46783] Fix | Delete
})(1);
[46784] Fix | Delete
var currentValue = interpolation$$1 && interpolation$$1.getValue(); // Change detection flags
[46785] Fix | Delete
[46786] Fix | Delete
var isFirst = is.und(parent);
[46787] Fix | Delete
var isActive = !isFirst && entry.animatedValues.some(function (v) {
[46788] Fix | Delete
return !v.done;
[46789] Fix | Delete
});
[46790] Fix | Delete
var currentValueDiffersFromGoal = !is.equ(newValue, currentValue);
[46791] Fix | Delete
var hasNewGoal = !is.equ(newValue, entry.previous);
[46792] Fix | Delete
var hasNewConfig = !is.equ(toConfig, entry.config); // Change animation props when props indicate a new goal (new value differs from previous one)
[46793] Fix | Delete
// and current values differ from it. Config changes trigger a new update as well (though probably shouldn't?)
[46794] Fix | Delete
[46795] Fix | Delete
if (reset || hasNewGoal && currentValueDiffersFromGoal || hasNewConfig) {
[46796] Fix | Delete
var _extends2;
[46797] Fix | Delete
[46798] Fix | Delete
// Convert regular values into animated values, ALWAYS re-use if possible
[46799] Fix | Delete
if (isNumber || isString) parent = interpolation$$1 = entry.parent || new AnimatedValue(fromValue);else if (isArray) parent = interpolation$$1 = entry.parent || new AnimatedValueArray(fromValue);else if (isInterpolation) {
[46800] Fix | Delete
var prev = entry.interpolation && entry.interpolation.calc(entry.parent.value);
[46801] Fix | Delete
prev = prev !== void 0 && !reset ? prev : fromValue;
[46802] Fix | Delete
[46803] Fix | Delete
if (entry.parent) {
[46804] Fix | Delete
parent = entry.parent;
[46805] Fix | Delete
parent.setValue(0, false);
[46806] Fix | Delete
} else parent = new AnimatedValue(0);
[46807] Fix | Delete
[46808] Fix | Delete
var range = {
[46809] Fix | Delete
output: [prev, value]
[46810] Fix | Delete
};
[46811] Fix | Delete
[46812] Fix | Delete
if (entry.interpolation) {
[46813] Fix | Delete
interpolation$$1 = entry.interpolation;
[46814] Fix | Delete
entry.interpolation.updateConfig(range);
[46815] Fix | Delete
} else interpolation$$1 = parent.interpolate(range);
[46816] Fix | Delete
}
[46817] Fix | Delete
toValues = toArray(target ? toValue.getPayload() : toValue);
[46818] Fix | Delete
animatedValues = toArray(parent.getPayload());
[46819] Fix | Delete
if (reset && !isInterpolation) parent.setValue(fromValue, false);
[46820] Fix | Delete
_this4.hasChanged = true; // Reset animated values
[46821] Fix | Delete
[46822] Fix | Delete
animatedValues.forEach(function (value) {
[46823] Fix | Delete
value.startPosition = value.value;
[46824] Fix | Delete
value.lastPosition = value.value;
[46825] Fix | Delete
value.lastVelocity = isActive ? value.lastVelocity : undefined;
[46826] Fix | Delete
value.lastTime = isActive ? value.lastTime : undefined;
[46827] Fix | Delete
value.startTime = now();
[46828] Fix | Delete
value.done = false;
[46829] Fix | Delete
value.animatedStyles.clear();
[46830] Fix | Delete
}); // Set immediate values
[46831] Fix | Delete
[46832] Fix | Delete
if (callProp(immediate, name)) {
[46833] Fix | Delete
parent.setValue(isInterpolation ? toValue : value, false);
[46834] Fix | Delete
}
[46835] Fix | Delete
[46836] Fix | Delete
return _extends({}, acc, (_extends2 = {}, _extends2[name] = _extends({}, entry, {
[46837] Fix | Delete
name: name,
[46838] Fix | Delete
parent: parent,
[46839] Fix | Delete
interpolation: interpolation$$1,
[46840] Fix | Delete
animatedValues: animatedValues,
[46841] Fix | Delete
toValues: toValues,
[46842] Fix | Delete
previous: newValue,
[46843] Fix | Delete
config: toConfig,
[46844] Fix | Delete
fromValues: toArray(parent.getValue()),
[46845] Fix | Delete
immediate: callProp(immediate, name),
[46846] Fix | Delete
initialVelocity: withDefault(toConfig.velocity, 0),
[46847] Fix | Delete
clamp: withDefault(toConfig.clamp, false),
[46848] Fix | Delete
precision: withDefault(toConfig.precision, 0.01),
[46849] Fix | Delete
tension: withDefault(toConfig.tension, 170),
[46850] Fix | Delete
friction: withDefault(toConfig.friction, 26),
[46851] Fix | Delete
mass: withDefault(toConfig.mass, 1),
[46852] Fix | Delete
duration: toConfig.duration,
[46853] Fix | Delete
easing: withDefault(toConfig.easing, function (t) {
[46854] Fix | Delete
return t;
[46855] Fix | Delete
}),
[46856] Fix | Delete
decay: toConfig.decay
[46857] Fix | Delete
}), _extends2));
[46858] Fix | Delete
} else {
[46859] Fix | Delete
if (!currentValueDiffersFromGoal) {
[46860] Fix | Delete
var _extends3;
[46861] Fix | Delete
[46862] Fix | Delete
// So ... the current target value (newValue) appears to be different from the previous value,
[46863] Fix | Delete
// which normally constitutes an update, but the actual value (currentValue) matches the target!
[46864] Fix | Delete
// In order to resolve this without causing an animation update we silently flag the animation as done,
[46865] Fix | Delete
// which it technically is. Interpolations also needs a config update with their target set to 1.
[46866] Fix | Delete
if (isInterpolation) {
[46867] Fix | Delete
parent.setValue(1, false);
[46868] Fix | Delete
interpolation$$1.updateConfig({
[46869] Fix | Delete
output: [newValue, newValue]
[46870] Fix | Delete
});
[46871] Fix | Delete
}
[46872] Fix | Delete
[46873] Fix | Delete
parent.done = true;
[46874] Fix | Delete
_this4.hasChanged = true;
[46875] Fix | Delete
return _extends({}, acc, (_extends3 = {}, _extends3[name] = _extends({}, acc[name], {
[46876] Fix | Delete
previous: newValue
[46877] Fix | Delete
}), _extends3));
[46878] Fix | Delete
}
[46879] Fix | Delete
[46880] Fix | Delete
return acc;
[46881] Fix | Delete
}
[46882] Fix | Delete
}, this.animations);
[46883] Fix | Delete
[46884] Fix | Delete
if (this.hasChanged) {
[46885] Fix | Delete
// Make animations available to frameloop
[46886] Fix | Delete
this.configs = Object.values(this.animations);
[46887] Fix | Delete
this.values = {};
[46888] Fix | Delete
this.interpolations = {};
[46889] Fix | Delete
[46890] Fix | Delete
for (var key in this.animations) {
[46891] Fix | Delete
this.interpolations[key] = this.animations[key].interpolation;
[46892] Fix | Delete
this.values[key] = this.animations[key].interpolation.getValue();
[46893] Fix | Delete
}
[46894] Fix | Delete
}
[46895] Fix | Delete
[46896] Fix | Delete
return this;
[46897] Fix | Delete
};
[46898] Fix | Delete
[46899] Fix | Delete
_proto.destroy = function destroy() {
[46900] Fix | Delete
this.stop();
[46901] Fix | Delete
this.props = {};
[46902] Fix | Delete
this.merged = {};
[46903] Fix | Delete
this.animations = {};
[46904] Fix | Delete
this.interpolations = {};
[46905] Fix | Delete
this.values = {};
[46906] Fix | Delete
this.configs = [];
[46907] Fix | Delete
this.local = 0;
[46908] Fix | Delete
};
[46909] Fix | Delete
[46910] Fix | Delete
return Controller;
[46911] Fix | Delete
}();
[46912] Fix | Delete
[46913] Fix | Delete
/** API
[46914] Fix | Delete
* const props = useSprings(number, [{ ... }, { ... }, ...])
[46915] Fix | Delete
* const [props, set] = useSprings(number, (i, controller) => ({ ... }))
[46916] Fix | Delete
*/
[46917] Fix | Delete
[46918] Fix | Delete
var useSprings = function useSprings(length, props) {
[46919] Fix | Delete
var mounted = React.useRef(false);
[46920] Fix | Delete
var ctrl = React.useRef();
[46921] Fix | Delete
var isFn = is.fun(props); // The controller maintains the animation values, starts and stops animations
[46922] Fix | Delete
[46923] Fix | Delete
var _useMemo = React.useMemo(function () {
[46924] Fix | Delete
// Remove old controllers
[46925] Fix | Delete
if (ctrl.current) {
[46926] Fix | Delete
ctrl.current.map(function (c) {
[46927] Fix | Delete
return c.destroy();
[46928] Fix | Delete
});
[46929] Fix | Delete
ctrl.current = undefined;
[46930] Fix | Delete
}
[46931] Fix | Delete
[46932] Fix | Delete
var ref;
[46933] Fix | Delete
return [new Array(length).fill().map(function (_, i) {
[46934] Fix | Delete
var ctrl = new Controller();
[46935] Fix | Delete
var newProps = isFn ? callProp(props, i, ctrl) : props[i];
[46936] Fix | Delete
if (i === 0) ref = newProps.ref;
[46937] Fix | Delete
ctrl.update(newProps);
[46938] Fix | Delete
if (!ref) ctrl.start();
[46939] Fix | Delete
return ctrl;
[46940] Fix | Delete
}), ref];
[46941] Fix | Delete
}, [length]),
[46942] Fix | Delete
controllers = _useMemo[0],
[46943] Fix | Delete
ref = _useMemo[1];
[46944] Fix | Delete
[46945] Fix | Delete
ctrl.current = controllers; // The hooks reference api gets defined here ...
[46946] Fix | Delete
[46947] Fix | Delete
var api = React.useImperativeHandle(ref, function () {
[46948] Fix | Delete
return {
[46949] Fix | Delete
start: function start() {
[46950] Fix | Delete
return Promise.all(ctrl.current.map(function (c) {
[46951] Fix | Delete
return new Promise(function (r) {
[46952] Fix | Delete
return c.start(r);
[46953] Fix | Delete
});
[46954] Fix | Delete
}));
[46955] Fix | Delete
},
[46956] Fix | Delete
stop: function stop(finished) {
[46957] Fix | Delete
return ctrl.current.forEach(function (c) {
[46958] Fix | Delete
return c.stop(finished);
[46959] Fix | Delete
});
[46960] Fix | Delete
},
[46961] Fix | Delete
[46962] Fix | Delete
get controllers() {
[46963] Fix | Delete
return ctrl.current;
[46964] Fix | Delete
}
[46965] Fix | Delete
[46966] Fix | Delete
};
[46967] Fix | Delete
}); // This function updates the controllers
[46968] Fix | Delete
[46969] Fix | Delete
var updateCtrl = React.useMemo(function () {
[46970] Fix | Delete
return function (updateProps) {
[46971] Fix | Delete
return ctrl.current.map(function (c, i) {
[46972] Fix | Delete
c.update(isFn ? callProp(updateProps, i, c) : updateProps[i]);
[46973] Fix | Delete
if (!ref) c.start();
[46974] Fix | Delete
});
[46975] Fix | Delete
};
[46976] Fix | Delete
}, [length]); // Update controller if props aren't functional
[46977] Fix | Delete
[46978] Fix | Delete
React.useEffect(function () {
[46979] Fix | Delete
if (mounted.current) {
[46980] Fix | Delete
if (!isFn) updateCtrl(props);
[46981] Fix | Delete
} else if (!ref) ctrl.current.forEach(function (c) {
[46982] Fix | Delete
return c.start();
[46983] Fix | Delete
});
[46984] Fix | Delete
}); // Update mounted flag and destroy controller on unmount
[46985] Fix | Delete
[46986] Fix | Delete
React.useEffect(function () {
[46987] Fix | Delete
return mounted.current = true, function () {
[46988] Fix | Delete
return ctrl.current.forEach(function (c) {
[46989] Fix | Delete
return c.destroy();
[46990] Fix | Delete
});
[46991] Fix | Delete
};
[46992] Fix | Delete
}, []); // Return animated props, or, anim-props + the update-setter above
[46993] Fix | Delete
[46994] Fix | Delete
var propValues = ctrl.current.map(function (c) {
[46995] Fix | Delete
return c.getValues();
[46996] Fix | Delete
});
[46997] Fix | Delete
return isFn ? [propValues, updateCtrl, function (finished) {
[46998] Fix | Delete
return ctrl.current.forEach(function (c) {
[46999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function