Files
discord-decomp/_bundle/DecayAnimation.js
T
2026-11-01 12:12:55 +02:00

113 lines
3.4 KiB
JavaScript

// Metro module 386 (f387).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import _possibleConstructorReturn from "./_possibleConstructorReturn";
import _getPrototypeOf from "./_getPrototypeOf";
import _get from "./_get";
import _inherits from "./_inherits";
import Animation from "./Animation";
function $mk66483($env) {
return function(a0) {
const r0 = $env;
return r0[1].apply(r0[0], a0);
};
}
let DecayAnimation;
let env416 = {};
env416[5] = function _isNativeReflectConstruct() {
let c12298_0;
try {
c12298_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c12298_0;
};
env416[5] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
DecayAnimation = function DecayAnimation(a0) {
_classCallCheck(this, DecayAnimation);
const r10 = [a0];
const r9 = _getPrototypeOf(DecayAnimation);
const r22 = _possibleConstructorReturn(this, (0, env416[5])() ? Reflect.construct(r9, r10, _getPrototypeOf(this).constructor) : r9.apply(this, r10));
let deceleration = a0.deceleration;
if (deceleration == null) {
deceleration = 0.998;
}
r22._deceleration = deceleration;
r22._velocity = a0.velocity;
r22._platformConfig = a0.platformConfig;
return r22;
};
_inherits(DecayAnimation, Animation);
export default _createClass(DecayAnimation, [{
key: "__getNativeAnimationConfig",
value: function __getNativeAnimationConfig() {
return {
type: "decay",
deceleration: this._deceleration,
velocity: this._velocity,
iterations: this.__iterations,
platformConfig: this._platformConfig,
debugID: this.__getDebugID()
};
}
}, {
key: "start",
value: function start(a0, a1, a2, a3, a4) {
let env23766;
const _this = this;
const r10 = env23766 = {};
env23766[0] = this;
const r15 = _get(_getPrototypeOf(DecayAnimation.prototype), "start", this);
env23766[1] = r15;
let r7 = r15;
if (typeof r7 === "function") {
r7 = $mk66483(r10);
}
r7([a0, a1, a2, a3, a4]);
this._lastValue = a0;
this._fromValue = a0;
this._onUpdate = a1;
this._startTime = Date.now();
if (!this.__startAnimationIfNative(a4)) {
this._animationFrame = requestAnimationFrame(() => _this.onUpdate());
}
}
}, {
key: "onUpdate",
value: function onUpdate() {
const _lastValue = this._fromValue + this._velocity / (1 - this._deceleration) * (1 - Math.exp(-(1 - this._deceleration) * (Date.now() - this._startTime)));
this._onUpdate(_lastValue);
if (Math.abs(this._lastValue - _lastValue) < 0.1) {
this.__notifyAnimationEnd({
finished: true
});
} else {
this._lastValue = _lastValue;
if (this.__active) {
this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this));
}
}
}
}, {
key: "stop",
value: function stop() {
let env23767;
const r8 = env23767 = {};
env23767[0] = this;
let r12 = _get(_getPrototypeOf(DecayAnimation.prototype), "stop", this);
env23767[1] = r12;
if (typeof r12 === "function") {
r12 = $mk66483(r8);
}
r12([]);
if (this._animationFrame != null) {
global.cancelAnimationFrame(this._animationFrame);
}
this.__notifyAnimationEnd({
finished: false
});
}
}]);