34 lines
2.1 KiB
JavaScript
34 lines
2.1 KiB
JavaScript
// Metro module 1683 (f1684).
|
|
import * as _Module1682 from "./Module1682";
|
|
export function rubberBandDecay(a0, a1, a2) {
|
|
const { lastTimestamp, startTimestamp, current, velocity } = a0;
|
|
const r20 = Math.min(Math.max(a1 - lastTimestamp, 0), 64);
|
|
const r33 = Math.abs(current - a2.clamp[0]) < Math.abs(current - a2.clamp[1]) ? 0 : 1;
|
|
const r39 = current < a2.clamp[0] || current > a2.clamp[1] ? current - a2.clamp[r33] : 0;
|
|
const velocity2 = velocity * Math.exp(-(1 - a2.deceleration) * (a1 - startTimestamp) * _Module1682.SLOPE_FACTOR) - r39 * a2.rubberBandFactor;
|
|
if (Math.abs(r39) > 0.1) {
|
|
a0.springActive = true;
|
|
} else {
|
|
if (a0.springActive) {
|
|
a0.current = a2.clamp[r33];
|
|
return true;
|
|
}
|
|
if (Math.abs(velocity2) < _Module1682.VELOCITY_EPS) {
|
|
return true;
|
|
}
|
|
}
|
|
a0.current = current + velocity2 * a2.velocityFactor * r20 / 1000;
|
|
a0.velocity = velocity2;
|
|
a0.lastTimestamp = a1;
|
|
return false;
|
|
}
|
|
rubberBandDecay.__closure = {
|
|
SLOPE_FACTOR: _Module1682.SLOPE_FACTOR,
|
|
DERIVATIVE_EPS: 0.1,
|
|
VELOCITY_EPS: _Module1682.VELOCITY_EPS
|
|
};
|
|
rubberBandDecay.__workletHash = 1153024330944;
|
|
rubberBandDecay.__initData = {
|
|
code: "function rubberBandDecay_Pnpm_rubberBandDecayTs1(animation,now,config){const{SLOPE_FACTOR,DERIVATIVE_EPS,VELOCITY_EPS}=this.__closure;const{lastTimestamp:lastTimestamp,startTimestamp:startTimestamp,current:current,velocity:velocity}=animation;const deltaTime=Math.min(Math.max(now-lastTimestamp,0),64);const clampIndex=Math.abs(current-config.clamp[0])<Math.abs(current-config.clamp[1])?0:1;let derivative=0;if(current<config.clamp[0]||current>config.clamp[1]){derivative=current-config.clamp[clampIndex];}const v=velocity*Math.exp(-(1-config.deceleration)*(now-startTimestamp)*SLOPE_FACTOR)-derivative*config.rubberBandFactor;if(Math.abs(derivative)>DERIVATIVE_EPS){animation.springActive=true;}else if(animation.springActive){animation.current=config.clamp[clampIndex];return true;}else if(Math.abs(v)<VELOCITY_EPS){return true;}animation.current=current+v*config.velocityFactor*deltaTime/1000;animation.velocity=v;animation.lastTimestamp=now;return false;}"
|
|
};
|