This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _InternalAnimatedValue = _interopRequireDefault(require("../core/InternalAnimatedValue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Animation {
static springDefaultState() {
return {
position: new _InternalAnimatedValue.default(0),
finished: new _InternalAnimatedValue.default(0),
velocity: new _InternalAnimatedValue.default(0),
time: new _InternalAnimatedValue.default(0)
};
}
static decayDefaultState() {
return {
position: new _InternalAnimatedValue.default(0),
finished: new _InternalAnimatedValue.default(0),
velocity: new _InternalAnimatedValue.default(0),
time: new _InternalAnimatedValue.default(0)
};
}
static timingDefaultState() {
return {
position: new _InternalAnimatedValue.default(0),
finished: new _InternalAnimatedValue.default(0),
time: new _InternalAnimatedValue.default(0),
frameTime: new _InternalAnimatedValue.default(0)
};
}
}
var _default = Animation;
exports.default = _default;
//# sourceMappingURL=Animation.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["Animation.js"],"names":["Animation","springDefaultState","position","AnimatedValue","finished","velocity","time","decayDefaultState","timingDefaultState","frameTime"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,SAAN,CAAgB;AACd,SAAOC,kBAAP,GAA4B;AAC1B,WAAO;AACLC,MAAAA,QAAQ,EAAE,IAAIC,8BAAJ,CAAkB,CAAlB,CADL;AAELC,MAAAA,QAAQ,EAAE,IAAID,8BAAJ,CAAkB,CAAlB,CAFL;AAGLE,MAAAA,QAAQ,EAAE,IAAIF,8BAAJ,CAAkB,CAAlB,CAHL;AAILG,MAAAA,IAAI,EAAE,IAAIH,8BAAJ,CAAkB,CAAlB;AAJD,KAAP;AAMD;;AAED,SAAOI,iBAAP,GAA2B;AACzB,WAAO;AACLL,MAAAA,QAAQ,EAAE,IAAIC,8BAAJ,CAAkB,CAAlB,CADL;AAELC,MAAAA,QAAQ,EAAE,IAAID,8BAAJ,CAAkB,CAAlB,CAFL;AAGLE,MAAAA,QAAQ,EAAE,IAAIF,8BAAJ,CAAkB,CAAlB,CAHL;AAILG,MAAAA,IAAI,EAAE,IAAIH,8BAAJ,CAAkB,CAAlB;AAJD,KAAP;AAMD;;AAED,SAAOK,kBAAP,GAA4B;AAC1B,WAAO;AACLN,MAAAA,QAAQ,EAAE,IAAIC,8BAAJ,CAAkB,CAAlB,CADL;AAELC,MAAAA,QAAQ,EAAE,IAAID,8BAAJ,CAAkB,CAAlB,CAFL;AAGLG,MAAAA,IAAI,EAAE,IAAIH,8BAAJ,CAAkB,CAAlB,CAHD;AAILM,MAAAA,SAAS,EAAE,IAAIN,8BAAJ,CAAkB,CAAlB;AAJN,KAAP;AAMD;;AA1Ba;;eA6BDH,S","sourcesContent":["import AnimatedValue from '../core/InternalAnimatedValue';\n\nclass Animation {\n static springDefaultState() {\n return {\n position: new AnimatedValue(0),\n finished: new AnimatedValue(0),\n velocity: new AnimatedValue(0),\n time: new AnimatedValue(0),\n };\n }\n\n static decayDefaultState() {\n return {\n position: new AnimatedValue(0),\n finished: new AnimatedValue(0),\n velocity: new AnimatedValue(0),\n time: new AnimatedValue(0),\n };\n }\n\n static timingDefaultState() {\n return {\n position: new AnimatedValue(0),\n finished: new AnimatedValue(0),\n time: new AnimatedValue(0),\n frameTime: new AnimatedValue(0),\n };\n }\n}\n\nexport default Animation;\n"]}

View File

@ -0,0 +1,179 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _base = require("./../base");
var _InternalAnimatedValue = _interopRequireDefault(require("./../core/InternalAnimatedValue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function stiffnessFromOrigamiValue(oValue) {
return (oValue - 30) * 3.62 + 194;
}
function dampingFromOrigamiValue(oValue) {
return (oValue - 8) * 3 + 25;
}
function stiffnessFromOrigamiNode(oValue) {
return (0, _base.add)((0, _base.multiply)((0, _base.sub)(oValue, 30), 3.62), 194);
}
function dampingFromOrigamiNode(oValue) {
return (0, _base.add)((0, _base.multiply)((0, _base.sub)(oValue, 8), 3), 25);
}
function makeConfigFromOrigamiTensionAndFriction(prevConfig) {
const {
tension,
friction
} = prevConfig,
rest = _objectWithoutProperties(prevConfig, ["tension", "friction"]);
return _objectSpread(_objectSpread({}, rest), {}, {
stiffness: typeof tension === 'number' ? stiffnessFromOrigamiValue(tension) : stiffnessFromOrigamiNode(tension),
damping: typeof friction === 'number' ? dampingFromOrigamiValue(friction) : dampingFromOrigamiNode(friction)
});
}
function makeConfigFromBouncinessAndSpeed(prevConfig) {
const {
bounciness,
speed
} = prevConfig,
rest = _objectWithoutProperties(prevConfig, ["bounciness", "speed"]);
if (typeof bounciness === 'number' && typeof speed === 'number') {
return fromBouncinessAndSpeedNumbers(bounciness, speed, rest);
}
return fromBouncinessAndSpeedNodes(bounciness, speed, rest);
}
function fromBouncinessAndSpeedNodes(bounciness, speed, rest) {
function normalize(value, startValue, endValue) {
return (0, _base.divide)((0, _base.sub)(value, startValue), (0, _base.sub)(endValue, startValue));
}
function projectNormal(n, start, end) {
return (0, _base.add)(start, (0, _base.multiply)(n, (0, _base.sub)(end, start)));
}
function linearInterpolation(t, start, end) {
return (0, _base.add)((0, _base.multiply)(t, end), (0, _base.multiply)((0, _base.sub)(1, t), start));
}
function quadraticOutInterpolation(t, start, end) {
return linearInterpolation((0, _base.sub)((0, _base.multiply)(2, t), (0, _base.multiply)(t, t)), start, end);
}
function b3Friction1(x) {
return (0, _base.add)((0, _base.sub)((0, _base.multiply)(0.0007, (0, _base.pow)(x, 3)), (0, _base.multiply)(0.031, (0, _base.pow)(x, 2))), (0, _base.multiply)(0.64, x), 1.28);
}
function b3Friction2(x) {
return (0, _base.add)((0, _base.sub)((0, _base.multiply)(0.000044, (0, _base.pow)(x, 3)), (0, _base.multiply)(0.006, (0, _base.pow)(x, 2))), (0, _base.multiply)(0.36, x), 2);
}
function b3Friction3(x) {
return (0, _base.add)((0, _base.sub)((0, _base.multiply)(0.00000045, (0, _base.pow)(x, 3)), (0, _base.multiply)(0.000332, (0, _base.pow)(x, 2))), (0, _base.multiply)(0.1078, x), 5.84);
}
function b3Nobounce(tension) {
return (0, _base.cond)((0, _base.lessOrEq)(tension, 18), b3Friction1(tension), (0, _base.cond)((0, _base.and)((0, _base.greaterThan)(tension, 18), (0, _base.lessOrEq)(tension, 44)), b3Friction2(tension), b3Friction3(tension)));
}
let b = normalize((0, _base.divide)(bounciness, 1.7), 0, 20);
b = projectNormal(b, 0, 0.8);
const s = normalize((0, _base.divide)(speed, 1.7), 0, 20);
const bouncyTension = projectNormal(s, 0.5, 200);
const bouncyFriction = quadraticOutInterpolation(b, b3Nobounce(bouncyTension), 0.01);
return _objectSpread(_objectSpread({}, rest), {}, {
stiffness: stiffnessFromOrigamiNode(bouncyTension),
damping: dampingFromOrigamiNode(bouncyFriction)
});
}
function fromBouncinessAndSpeedNumbers(bounciness, speed, rest) {
function normalize(value, startValue, endValue) {
return (value - startValue) / (endValue - startValue);
}
function projectNormal(n, start, end) {
return start + n * (end - start);
}
function linearInterpolation(t, start, end) {
return t * end + (1 - t) * start;
}
function quadraticOutInterpolation(t, start, end) {
return linearInterpolation(2 * t - t * t, start, end);
}
function b3Friction1(x) {
return 0.0007 * Math.pow(x, 3) - 0.031 * Math.pow(x, 2) + 0.64 * x + 1.28;
}
function b3Friction2(x) {
return 0.000044 * Math.pow(x, 3) - 0.006 * Math.pow(x, 2) + 0.36 * x + 2;
}
function b3Friction3(x) {
return 0.00000045 * Math.pow(x, 3) - 0.000332 * Math.pow(x, 2) + 0.1078 * x + 5.84;
}
function b3Nobounce(tension) {
if (tension <= 18) {
return b3Friction1(tension);
} else if (tension > 18 && tension <= 44) {
return b3Friction2(tension);
} else {
return b3Friction3(tension);
}
}
let b = normalize(bounciness / 1.7, 0, 20);
b = projectNormal(b, 0, 0.8);
const s = normalize(speed / 1.7, 0, 20);
const bouncyTension = projectNormal(s, 0.5, 200);
const bouncyFriction = quadraticOutInterpolation(b, b3Nobounce(bouncyTension), 0.01);
return _objectSpread(_objectSpread({}, rest), {}, {
stiffness: stiffnessFromOrigamiValue(bouncyTension),
damping: dampingFromOrigamiValue(bouncyFriction)
});
}
function makeDefaultConfig() {
return {
stiffness: new _InternalAnimatedValue.default(100),
mass: new _InternalAnimatedValue.default(1),
damping: new _InternalAnimatedValue.default(10),
overshootClamping: false,
restSpeedThreshold: 0.001,
restDisplacementThreshold: 0.001,
toValue: new _InternalAnimatedValue.default(0)
};
}
var _default = {
makeDefaultConfig,
makeConfigFromBouncinessAndSpeed,
makeConfigFromOrigamiTensionAndFriction
};
exports.default = _default;
//# sourceMappingURL=SpringUtils.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = backwardsCompatibleAnimWrapper;
var _base = require("../base");
var _AnimatedClock = _interopRequireDefault(require("../core/AnimatedClock"));
var _evaluateOnce = require("../derived/evaluateOnce");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createOldAnimationObject(node, animationStateDefaults, value, config) {
const newClock = new _AnimatedClock.default();
const currentState = animationStateDefaults();
let alwaysNode;
let isStarted = false;
let isDone = false;
let wasStopped = false;
let animationCallback;
const animation = {
start: currentAnimationCallback => {
animationCallback = currentAnimationCallback;
if (isStarted) {
animationCallback && animationCallback({
finished: false
});
return;
}
if (isDone) {
console.warn('Animation has been finished before'); // inconsistent with React Native
return;
}
if (!value.isNativelyInitialized()) {
return;
}
isStarted = true;
(0, _evaluateOnce.evaluateOnce)((0, _base.set)(currentState.position, value), currentState.position, () => {
alwaysNode = (0, _base.always)((0, _base.set)(value, (0, _base.block)([(0, _base.cond)((0, _base.clockRunning)(newClock), 0, (0, _base.startClock)(newClock)), node(newClock, currentState, config), (0, _base.cond)(currentState.finished, [(0, _base.call)([], () => {
isStarted = false;
if (!wasStopped) {
isDone = true;
}
value.__detachAnimation(animation);
isDone = true;
if (!wasStopped) {
wasStopped = false;
}
}), (0, _base.stopClock)(newClock)]), currentState.position])));
value.__attachAnimation(animation);
alwaysNode.__addChild(value);
});
},
__detach: () => {
animationCallback && animationCallback({
finished: isDone
});
animationCallback = null;
value.__initialized && alwaysNode.__removeChild(value);
},
stop: () => {
if (isDone) {
console.warn('Calling stop has no effect as the animation has already completed');
return;
}
if (!isStarted) {
console.warn("Calling stop has no effect as the animation hasn't been started");
return;
}
wasStopped = true;
(0, _evaluateOnce.evaluateOnce)((0, _base.set)(currentState.finished, 1), currentState.finished);
},
__stopImmediately_testOnly: result => {
animation.stop();
isDone = result;
value.__detachAnimation(animation);
}
};
return animation;
}
/**
* Depending on the arguments list we either return animation node or return an
* animation object that is compatible with the original Animated API
*/
function backwardsCompatibleAnimWrapper(node, animationStateDefaults) {
return (clock, state, config) => {
if (config !== undefined) {
return node(clock, state, config);
}
return createOldAnimationObject(node, animationStateDefaults, clock, state);
};
}
//# sourceMappingURL=backwardCompatibleAnimWrapper.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _base = require("../base");
const VELOCITY_EPS = 5;
function decay(clock, state, config) {
const lastTime = (0, _base.cond)(state.time, state.time, clock);
const deltaTime = (0, _base.sub)(clock, lastTime); // v0 = v / 1000
// v = v0 * powf(deceleration, dt);
// v = v * 1000;
// x0 = x;
// x = x0 + v0 * deceleration * (1 - powf(deceleration, dt)) / (1 - deceleration)
const kv = (0, _base.pow)(config.deceleration, deltaTime);
const kx = (0, _base.divide)((0, _base.multiply)(config.deceleration, (0, _base.sub)(1, kv)), (0, _base.sub)(1, config.deceleration));
const v0 = (0, _base.divide)(state.velocity, 1000);
const v = (0, _base.multiply)(v0, kv, 1000);
const x = (0, _base.add)(state.position, (0, _base.multiply)(v0, kx));
return (0, _base.block)([(0, _base.set)(state.position, x), (0, _base.set)(state.velocity, v), (0, _base.set)(state.time, clock), (0, _base.cond)((0, _base.lessThan)((0, _base.abs)(v), VELOCITY_EPS), (0, _base.set)(state.finished, 1))]);
}
const procDecay = (0, _base.proc)((clock, time, velocity, position, finished, deceleration) => decay(clock, {
time,
velocity,
position,
finished
}, {
deceleration
}));
var _default = (clock, {
time,
velocity,
position,
finished
}, {
deceleration
}) => procDecay(clock, time, velocity, position, finished, deceleration);
exports.default = _default;
//# sourceMappingURL=decay.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["decay.js"],"names":["VELOCITY_EPS","decay","clock","state","config","lastTime","time","deltaTime","kv","deceleration","kx","v0","velocity","v","x","position","finished","procDecay"],"mappings":";;;;;;;AAAA;;AAcA,MAAMA,YAAY,GAAG,CAArB;;AAEA,SAASC,KAAT,CAAeC,KAAf,EAAsBC,KAAtB,EAA6BC,MAA7B,EAAqC;AACnC,QAAMC,QAAQ,GAAG,gBAAKF,KAAK,CAACG,IAAX,EAAiBH,KAAK,CAACG,IAAvB,EAA6BJ,KAA7B,CAAjB;AACA,QAAMK,SAAS,GAAG,eAAIL,KAAJ,EAAWG,QAAX,CAAlB,CAFmC,CAInC;AACA;AACA;AAEA;AACA;;AACA,QAAMG,EAAE,GAAG,eAAIJ,MAAM,CAACK,YAAX,EAAyBF,SAAzB,CAAX;AACA,QAAMG,EAAE,GAAG,kBACT,oBAASN,MAAM,CAACK,YAAhB,EAA8B,eAAI,CAAJ,EAAOD,EAAP,CAA9B,CADS,EAET,eAAI,CAAJ,EAAOJ,MAAM,CAACK,YAAd,CAFS,CAAX;AAIA,QAAME,EAAE,GAAG,kBAAOR,KAAK,CAACS,QAAb,EAAuB,IAAvB,CAAX;AACA,QAAMC,CAAC,GAAG,oBAASF,EAAT,EAAaH,EAAb,EAAiB,IAAjB,CAAV;AACA,QAAMM,CAAC,GAAG,eAAIX,KAAK,CAACY,QAAV,EAAoB,oBAASJ,EAAT,EAAaD,EAAb,CAApB,CAAV;AACA,SAAO,iBAAM,CACX,eAAIP,KAAK,CAACY,QAAV,EAAoBD,CAApB,CADW,EAEX,eAAIX,KAAK,CAACS,QAAV,EAAoBC,CAApB,CAFW,EAGX,eAAIV,KAAK,CAACG,IAAV,EAAgBJ,KAAhB,CAHW,EAIX,gBAAK,oBAAS,eAAIW,CAAJ,CAAT,EAAiBb,YAAjB,CAAL,EAAqC,eAAIG,KAAK,CAACa,QAAV,EAAoB,CAApB,CAArC,CAJW,CAAN,CAAP;AAMD;;AAED,MAAMC,SAAS,GAAG,gBAChB,CAACf,KAAD,EAAQI,IAAR,EAAcM,QAAd,EAAwBG,QAAxB,EAAkCC,QAAlC,EAA4CP,YAA5C,KACER,KAAK,CAACC,KAAD,EAAQ;AAAEI,EAAAA,IAAF;AAAQM,EAAAA,QAAR;AAAkBG,EAAAA,QAAlB;AAA4BC,EAAAA;AAA5B,CAAR,EAAgD;AAAEP,EAAAA;AAAF,CAAhD,CAFS,CAAlB;;eAKe,CACbP,KADa,EAEb;AAAEI,EAAAA,IAAF;AAAQM,EAAAA,QAAR;AAAkBG,EAAAA,QAAlB;AAA4BC,EAAAA;AAA5B,CAFa,EAGb;AAAEP,EAAAA;AAAF,CAHa,KAIVQ,SAAS,CAACf,KAAD,EAAQI,IAAR,EAAcM,QAAd,EAAwBG,QAAxB,EAAkCC,QAAlC,EAA4CP,YAA5C,C","sourcesContent":["import {\n cond,\n sub,\n pow,\n divide,\n multiply,\n add,\n block,\n set,\n lessThan,\n proc,\n abs,\n} from '../base';\n\nconst VELOCITY_EPS = 5;\n\nfunction decay(clock, state, config) {\n const lastTime = cond(state.time, state.time, clock);\n const deltaTime = sub(clock, lastTime);\n\n // v0 = v / 1000\n // v = v0 * powf(deceleration, dt);\n // v = v * 1000;\n\n // x0 = x;\n // x = x0 + v0 * deceleration * (1 - powf(deceleration, dt)) / (1 - deceleration)\n const kv = pow(config.deceleration, deltaTime);\n const kx = divide(\n multiply(config.deceleration, sub(1, kv)),\n sub(1, config.deceleration)\n );\n const v0 = divide(state.velocity, 1000);\n const v = multiply(v0, kv, 1000);\n const x = add(state.position, multiply(v0, kx));\n return block([\n set(state.position, x),\n set(state.velocity, v),\n set(state.time, clock),\n cond(lessThan(abs(v), VELOCITY_EPS), set(state.finished, 1)),\n ]);\n}\n\nconst procDecay = proc(\n (clock, time, velocity, position, finished, deceleration) =>\n decay(clock, { time, velocity, position, finished }, { deceleration })\n);\n\nexport default (\n clock,\n { time, velocity, position, finished },\n { deceleration }\n) => procDecay(clock, time, velocity, position, finished, deceleration);\n"]}

View File

@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _base = require("../base");
var _InternalAnimatedValue = _interopRequireDefault(require("../core/InternalAnimatedValue"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const MAX_STEPS_MS = 64;
function spring(clock, state, config) {
const lastTime = (0, _base.cond)(state.time, state.time, clock);
const deltaTime = (0, _base.min)((0, _base.sub)(clock, lastTime), MAX_STEPS_MS);
const c = config.damping;
const m = config.mass;
const k = config.stiffness;
const v0 = (0, _base.multiply)(-1, state.velocity);
const x0 = (0, _base.sub)(config.toValue, state.position);
const zeta = (0, _base.divide)(c, (0, _base.multiply)(2, (0, _base.sqrt)((0, _base.multiply)(k, m)))); // damping ratio
const omega0 = (0, _base.sqrt)((0, _base.divide)(k, m)); // undamped angular frequency of the oscillator (rad/ms)
const omega1 = (0, _base.multiply)(omega0, (0, _base.sqrt)((0, _base.sub)(1, (0, _base.multiply)(zeta, zeta)))); // exponential decay
const t = (0, _base.divide)(deltaTime, 1000); // in seconds
const sin1 = (0, _base.sin)((0, _base.multiply)(omega1, t));
const cos1 = (0, _base.cos)((0, _base.multiply)(omega1, t)); // under damped
const underDampedEnvelope = (0, _base.exp)((0, _base.multiply)(-1, zeta, omega0, t));
const underDampedFrag1 = (0, _base.multiply)(underDampedEnvelope, (0, _base.add)((0, _base.multiply)(sin1, (0, _base.divide)((0, _base.add)(v0, (0, _base.multiply)(zeta, omega0, x0)), omega1)), (0, _base.multiply)(x0, cos1)));
const underDampedPosition = (0, _base.sub)(config.toValue, underDampedFrag1); // This looks crazy -- it's actually just the derivative of the oscillation function
const underDampedVelocity = (0, _base.sub)((0, _base.multiply)(zeta, omega0, underDampedFrag1), (0, _base.multiply)(underDampedEnvelope, (0, _base.sub)((0, _base.multiply)(cos1, (0, _base.add)(v0, (0, _base.multiply)(zeta, omega0, x0))), (0, _base.multiply)(omega1, x0, sin1)))); // critically damped
const criticallyDampedEnvelope = (0, _base.exp)((0, _base.multiply)(-1, omega0, t));
const criticallyDampedPosition = (0, _base.sub)(config.toValue, (0, _base.multiply)(criticallyDampedEnvelope, (0, _base.add)(x0, (0, _base.multiply)((0, _base.add)(v0, (0, _base.multiply)(omega0, x0)), t))));
const criticallyDampedVelocity = (0, _base.multiply)(criticallyDampedEnvelope, (0, _base.add)((0, _base.multiply)(v0, (0, _base.sub)((0, _base.multiply)(t, omega0), 1)), (0, _base.multiply)(t, x0, omega0, omega0))); // conditions for stopping the spring animations
const prevPosition = state.prevPosition ? state.prevPosition : new _InternalAnimatedValue.default(0);
const isOvershooting = (0, _base.cond)((0, _base.and)(config.overshootClamping, (0, _base.neq)(config.stiffness, 0)), (0, _base.cond)((0, _base.lessThan)(prevPosition, config.toValue), (0, _base.greaterThan)(state.position, config.toValue), (0, _base.lessThan)(state.position, config.toValue)));
const isVelocity = (0, _base.lessThan)((0, _base.abs)(state.velocity), config.restSpeedThreshold);
const isDisplacement = (0, _base.or)((0, _base.eq)(config.stiffness, 0), (0, _base.lessThan)((0, _base.abs)((0, _base.sub)(config.toValue, state.position)), config.restDisplacementThreshold));
return (0, _base.block)([(0, _base.set)(prevPosition, state.position), (0, _base.cond)((0, _base.lessThan)(zeta, 1), [(0, _base.set)(state.position, underDampedPosition), (0, _base.set)(state.velocity, underDampedVelocity)], [(0, _base.set)(state.position, criticallyDampedPosition), (0, _base.set)(state.velocity, criticallyDampedVelocity)]), (0, _base.set)(state.time, clock), (0, _base.cond)((0, _base.or)(isOvershooting, (0, _base.and)(isVelocity, isDisplacement)), [(0, _base.cond)((0, _base.neq)(config.stiffness, 0), [(0, _base.set)(state.velocity, 0), (0, _base.set)(state.position, config.toValue)]), (0, _base.set)(state.finished, 1)])]);
}
const procSpring = (0, _base.proc)((finished, velocity, position, time, prevPosition, toValue, damping, mass, stiffness, overshootClamping, restSpeedThreshold, restDisplacementThreshold, clock) => spring(clock, {
finished,
velocity,
position,
time,
// @ts-ignore
prevPosition
}, {
toValue,
damping,
mass,
stiffness,
overshootClamping,
restDisplacementThreshold,
restSpeedThreshold
}));
var _default = (clock, {
finished,
velocity,
position,
time,
// @ts-ignore
prevPosition
}, {
toValue,
damping,
mass,
stiffness,
overshootClamping,
restDisplacementThreshold,
restSpeedThreshold
}) => procSpring(finished, velocity, position, time, prevPosition, toValue, damping, mass, stiffness, overshootClamping, restSpeedThreshold, restDisplacementThreshold, clock);
exports.default = _default;
//# sourceMappingURL=spring.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _base = require("../base");
const internalTiming = (0, _base.proc)(function (clock, time, frameTime, position, finished, toValue, duration, nextProgress, progress, newFrameTime) {
const state = {
time,
finished,
frameTime,
position
};
const config = {
duration,
toValue
};
const distanceLeft = (0, _base.sub)(config.toValue, state.position);
const fullDistance = (0, _base.divide)(distanceLeft, (0, _base.sub)(1, progress));
const startPosition = (0, _base.sub)(config.toValue, fullDistance);
const nextPosition = (0, _base.add)(startPosition, (0, _base.multiply)(fullDistance, nextProgress));
return (0, _base.block)([(0, _base.cond)((0, _base.greaterOrEq)(newFrameTime, config.duration), [(0, _base.set)(state.position, config.toValue), (0, _base.set)(state.finished, 1)], (0, _base.set)(state.position, nextPosition)), (0, _base.set)(state.frameTime, newFrameTime), (0, _base.set)(state.time, clock)]);
});
function _default(clock, state, config) {
if (config.duration === 0) {
// when duration is zero we end the timing immediately
return (0, _base.block)([(0, _base.set)(state.position, config.toValue), (0, _base.set)(state.finished, 1)]);
}
const lastTime = (0, _base.cond)(state.time, state.time, clock);
const newFrameTime = (0, _base.add)(state.frameTime, (0, _base.sub)(clock, lastTime));
const nextProgress = config.easing((0, _base.divide)(newFrameTime, config.duration));
const progress = config.easing((0, _base.divide)(state.frameTime, config.duration));
return internalTiming(clock, state.time, state.frameTime, state.position, state.finished, config.toValue, config.duration, nextProgress, progress, newFrameTime);
}
//# sourceMappingURL=timing.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["timing.js"],"names":["internalTiming","clock","time","frameTime","position","finished","toValue","duration","nextProgress","progress","newFrameTime","state","config","distanceLeft","fullDistance","startPosition","nextPosition","lastTime","easing"],"mappings":";;;;;;;AAAA;;AAYA,MAAMA,cAAc,GAAG,gBAAK,UAC1BC,KAD0B,EAE1BC,IAF0B,EAG1BC,SAH0B,EAI1BC,QAJ0B,EAK1BC,QAL0B,EAM1BC,OAN0B,EAO1BC,QAP0B,EAQ1BC,YAR0B,EAS1BC,QAT0B,EAU1BC,YAV0B,EAW1B;AACA,QAAMC,KAAK,GAAG;AACZT,IAAAA,IADY;AAEZG,IAAAA,QAFY;AAGZF,IAAAA,SAHY;AAIZC,IAAAA;AAJY,GAAd;AAOA,QAAMQ,MAAM,GAAG;AACbL,IAAAA,QADa;AAEbD,IAAAA;AAFa,GAAf;AAKA,QAAMO,YAAY,GAAG,eAAID,MAAM,CAACN,OAAX,EAAoBK,KAAK,CAACP,QAA1B,CAArB;AACA,QAAMU,YAAY,GAAG,kBAAOD,YAAP,EAAqB,eAAI,CAAJ,EAAOJ,QAAP,CAArB,CAArB;AACA,QAAMM,aAAa,GAAG,eAAIH,MAAM,CAACN,OAAX,EAAoBQ,YAApB,CAAtB;AACA,QAAME,YAAY,GAAG,eAAID,aAAJ,EAAmB,oBAASD,YAAT,EAAuBN,YAAvB,CAAnB,CAArB;AAEA,SAAO,iBAAM,CACX,gBACE,uBAAYE,YAAZ,EAA0BE,MAAM,CAACL,QAAjC,CADF,EAEE,CAAC,eAAII,KAAK,CAACP,QAAV,EAAoBQ,MAAM,CAACN,OAA3B,CAAD,EAAsC,eAAIK,KAAK,CAACN,QAAV,EAAoB,CAApB,CAAtC,CAFF,EAGE,eAAIM,KAAK,CAACP,QAAV,EAAoBY,YAApB,CAHF,CADW,EAMX,eAAIL,KAAK,CAACR,SAAV,EAAqBO,YAArB,CANW,EAOX,eAAIC,KAAK,CAACT,IAAV,EAAgBD,KAAhB,CAPW,CAAN,CAAP;AASD,CAtCsB,CAAvB;;AAwCe,kBAASA,KAAT,EAAgBU,KAAhB,EAAuBC,MAAvB,EAA+B;AAC5C,MAAIA,MAAM,CAACL,QAAP,KAAoB,CAAxB,EAA2B;AACzB;AACA,WAAO,iBAAM,CAAC,eAAII,KAAK,CAACP,QAAV,EAAoBQ,MAAM,CAACN,OAA3B,CAAD,EAAsC,eAAIK,KAAK,CAACN,QAAV,EAAoB,CAApB,CAAtC,CAAN,CAAP;AACD;;AACD,QAAMY,QAAQ,GAAG,gBAAKN,KAAK,CAACT,IAAX,EAAiBS,KAAK,CAACT,IAAvB,EAA6BD,KAA7B,CAAjB;AACA,QAAMS,YAAY,GAAG,eAAIC,KAAK,CAACR,SAAV,EAAqB,eAAIF,KAAJ,EAAWgB,QAAX,CAArB,CAArB;AACA,QAAMT,YAAY,GAAGI,MAAM,CAACM,MAAP,CAAc,kBAAOR,YAAP,EAAqBE,MAAM,CAACL,QAA5B,CAAd,CAArB;AACA,QAAME,QAAQ,GAAGG,MAAM,CAACM,MAAP,CAAc,kBAAOP,KAAK,CAACR,SAAb,EAAwBS,MAAM,CAACL,QAA/B,CAAd,CAAjB;AACA,SAAOP,cAAc,CACnBC,KADmB,EAEnBU,KAAK,CAACT,IAFa,EAGnBS,KAAK,CAACR,SAHa,EAInBQ,KAAK,CAACP,QAJa,EAKnBO,KAAK,CAACN,QALa,EAMnBO,MAAM,CAACN,OANY,EAOnBM,MAAM,CAACL,QAPY,EAQnBC,YARmB,EASnBC,QATmB,EAUnBC,YAVmB,CAArB;AAYD","sourcesContent":["import {\n cond,\n sub,\n divide,\n multiply,\n add,\n block,\n set,\n greaterOrEq,\n proc,\n} from '../base';\n\nconst internalTiming = proc(function(\n clock,\n time,\n frameTime,\n position,\n finished,\n toValue,\n duration,\n nextProgress,\n progress,\n newFrameTime\n) {\n const state = {\n time,\n finished,\n frameTime,\n position,\n };\n\n const config = {\n duration,\n toValue,\n };\n\n const distanceLeft = sub(config.toValue, state.position);\n const fullDistance = divide(distanceLeft, sub(1, progress));\n const startPosition = sub(config.toValue, fullDistance);\n const nextPosition = add(startPosition, multiply(fullDistance, nextProgress));\n\n return block([\n cond(\n greaterOrEq(newFrameTime, config.duration),\n [set(state.position, config.toValue), set(state.finished, 1)],\n set(state.position, nextPosition)\n ),\n set(state.frameTime, newFrameTime),\n set(state.time, clock),\n ]);\n});\n\nexport default function(clock, state, config) {\n if (config.duration === 0) {\n // when duration is zero we end the timing immediately\n return block([set(state.position, config.toValue), set(state.finished, 1)]);\n }\n const lastTime = cond(state.time, state.time, clock);\n const newFrameTime = add(state.frameTime, sub(clock, lastTime));\n const nextProgress = config.easing(divide(newFrameTime, config.duration));\n const progress = config.easing(divide(state.frameTime, config.duration));\n return internalTiming(\n clock,\n state.time,\n state.frameTime,\n state.position,\n state.finished,\n config.toValue,\n config.duration,\n nextProgress,\n progress,\n newFrameTime\n );\n}\n"]}