motion-dom 14.12.0 → 14.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +275 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/generators/spring.mjs +3 -3
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/gestures/pinch/index.mjs +2 -3
- package/dist/es/gestures/pinch/index.mjs.map +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/projection/animation/layout-velocity.mjs +28 -0
- package/dist/es/projection/animation/layout-velocity.mjs.map +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +251 -7
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/index.d.ts +78 -6
- package/dist/motion-dom.dev.js +275 -11
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-pinch.js +1 -1
- package/dist/size-rollup-pinch.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { secondsToMilliseconds,
|
|
1
|
+
import { secondsToMilliseconds, warning, clamp, millisecondsToSeconds } from 'motion-utils';
|
|
2
2
|
import { generateLinearEasing } from '../waapi/utils/linear.mjs';
|
|
3
3
|
import { calcGeneratorDuration, maxGeneratorDuration } from './utils/calc-duration.mjs';
|
|
4
4
|
import { createGeneratorEasing } from './utils/create-generator-easing.mjs';
|
|
@@ -146,7 +146,7 @@ function resolvePhysics(value, canBeZero) {
|
|
|
146
146
|
if (isValidPhysics(value, canBeZero))
|
|
147
147
|
return value;
|
|
148
148
|
if (process.env.NODE_ENV !== "production") {
|
|
149
|
-
warning(value === undefined, "Spring stiffness and mass must be positive, damping 0 or greater", "spring-invalid-physics");
|
|
149
|
+
warning(value === undefined || value === "auto", "Spring stiffness and mass must be positive, damping 0 or greater", "spring-invalid-physics");
|
|
150
150
|
}
|
|
151
151
|
return undefined;
|
|
152
152
|
}
|
|
@@ -393,5 +393,5 @@ const spring = /* @__PURE__ */ Object.assign(springGenerator, {
|
|
|
393
393
|
},
|
|
394
394
|
});
|
|
395
395
|
|
|
396
|
-
export { spring };
|
|
396
|
+
export { getSpringOptions, spring };
|
|
397
397
|
//# sourceMappingURL=spring.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring.mjs","sources":["../../../../src/animation/generators/spring.ts"],"sourcesContent":["import {\n clamp,\n millisecondsToSeconds,\n secondsToMilliseconds,\n warning,\n} from \"motion-utils\"\nimport {\n AnimationState,\n KeyframeGenerator,\n SpringOptions,\n Transition,\n ValueAnimationOptions,\n} from \"../types\"\nimport { generateLinearEasing } from \"../waapi/utils/linear\"\nimport {\n calcGeneratorDuration,\n maxGeneratorDuration,\n} from \"./utils/calc-duration\"\nimport { createGeneratorEasing } from \"./utils/create-generator-easing\"\n\n// Default spring physics\nconst defaultStiffness = 100\nconst defaultDamping = 10\nconst defaultMass = 1.0\n\n// Default duration/bounce-based options\nconst defaultDuration = 800 // in ms\nconst defaultBounce = 0.3\nconst defaultVisualDuration = 0.3 // in seconds\n\n// Rest thresholds\nconst restSpeedGranular = 0.01\nconst restSpeedDefault = 2\nconst restDeltaGranular = 0.005\nconst restDeltaDefault = 0.5\n\n// Limits\nconst minDuration = 0.01 // in seconds\nconst maxDuration = 10.0 // in seconds\nconst minDamping = 0.05\n\n/**\n * Maps bounce to a damping ratio as SwiftUI does: 0 is critically damped, and\n * it approaches undamped towards 1 and infinitely overdamped towards -1. Both\n * ends are limited so the spring still moves and settles.\n */\nconst bounceToDampingRatio = (bounce: number) =>\n bounce < 0\n ? 1 / Math.max(1 + bounce, minDamping)\n : Math.max(1 - bounce, minDamping)\n\n/**\n * Scales an overdamped spring's undamped frequency so that, at its defining\n * time, it has as far left to go as the critically damped spring that's\n * criticalFreqTime radians in by then. A negative bounce then changes the\n * shape of the curve, not when it arrives. 1 at a damping ratio of 1, so\n * there's no jump at a bounce of 0.\n *\n * Solved by Newton on the remaining distance (times fast - slow), which is\n * convex from criticalFreqTime onwards. criticalFreqTime is always below the\n * answer, so it converges from below without overshooting.\n */\nfunction overdampedFreqScale(dampingRatio: number, criticalFreqTime: number) {\n if (!(dampingRatio > 1)) return 1\n\n const root = Math.sqrt(dampingRatio * dampingRatio - 1)\n const slow = dampingRatio - root\n const fast = dampingRatio + root\n const target =\n 2 * root * Math.exp(-criticalFreqTime) * (1 + criticalFreqTime)\n\n return (\n approximateRoot(\n (freqTime) =>\n fast * Math.exp(-slow * freqTime) -\n slow * Math.exp(-fast * freqTime) -\n target,\n (freqTime) =>\n Math.exp(-fast * freqTime) - Math.exp(-slow * freqTime),\n criticalFreqTime\n ) / criticalFreqTime\n )\n}\n\nfunction calcAngularFreq(undampedFreq: number, dampingRatio: number) {\n return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio)\n}\n\nconst rootIterations = 12\nfunction approximateRoot(\n envelope: (num: number) => number,\n derivative: (num: number) => number,\n initialGuess: number\n): number {\n let result = initialGuess\n for (let i = 1; i < rootIterations; i++) {\n result = result - envelope(result) / derivative(result)\n }\n return result\n}\n\n/**\n * This is ported from the Framer implementation of duration-based spring resolution.\n */\nconst safeMin = 0.001\n\n/**\n * Assumes zero initial velocity and the default mass: duration springs start\n * from rest so they end exactly at their duration. Only resolves without\n * valid physics. Returns NaN physics when the root search doesn't converge.\n */\nfunction findSpring({\n duration = defaultDuration,\n bounce = defaultBounce,\n}: SpringOptions) {\n let envelope: (num: number) => number\n let derivative: (num: number) => number\n\n process.env.NODE_ENV !== \"production\" &&\n warning(\n duration <= secondsToMilliseconds(maxDuration),\n \"Spring duration must be 10 seconds or less\",\n \"spring-duration-limit\"\n )\n\n const dampingRatio = bounceToDampingRatio(bounce)\n\n duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration))\n\n if (dampingRatio < 1) {\n /**\n * Underdamped spring\n */\n envelope = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio\n const delta = exponentialDecay * duration\n const b = calcAngularFreq(undampedFreq, dampingRatio)\n const c = Math.exp(-delta)\n return safeMin - (exponentialDecay / b) * c\n }\n\n derivative = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio\n const delta = exponentialDecay * duration\n const e =\n dampingRatio *\n dampingRatio *\n undampedFreq *\n undampedFreq *\n duration\n const f = Math.exp(-delta)\n const g = calcAngularFreq(undampedFreq * undampedFreq, dampingRatio)\n const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1\n return (factor * -e * f) / g\n }\n } else {\n /**\n * Critically-damped spring. Overdamped springs reuse this root,\n * scaled below.\n */\n envelope = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration)\n const b = undampedFreq * duration + 1\n return -safeMin + a * b\n }\n\n derivative = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration)\n const b = -undampedFreq * (duration * duration)\n return a * b\n }\n }\n\n const initialGuess = 5 / duration\n const criticalFreq = approximateRoot(envelope, derivative, initialGuess)\n const undampedFreq =\n criticalFreq *\n overdampedFreqScale(dampingRatio, criticalFreq * duration)\n const stiffness = undampedFreq * undampedFreq\n\n return {\n stiffness,\n damping: dampingRatio * 2 * Math.sqrt(stiffness),\n duration: secondsToMilliseconds(duration),\n }\n}\n\n/**\n * Spring physics must be finite. stiffness and mass are also divisors so must\n * be positive, whereas a damping of 0 is a valid, perpetually oscillating\n * spring. Relational rather than Number.isFinite so numeric strings still\n * coerce.\n */\nconst isValidPhysics = (value: number | undefined, canBeZero?: boolean) =>\n (canBeZero ? value! >= 0 : value! > 0) && value! < Infinity\n\n/**\n * Returns value if it's usable spring physics, otherwise undefined so callers\n * fall back to the default. An explicit `undefined`, e.g. from a forwarded\n * optional prop, must fall back too. Invalid physics would otherwise resolve\n * to NaN spring values that never report done.\n */\nfunction resolvePhysics(value: number | undefined, canBeZero?: boolean) {\n if (isValidPhysics(value, canBeZero)) return value\n\n if (process.env.NODE_ENV !== \"production\") {\n warning(\n value === undefined,\n \"Spring stiffness and mass must be positive, damping 0 or greater\",\n \"spring-invalid-physics\"\n )\n }\n\n return undefined\n}\n\nfunction getSpringOptions(options: SpringOptions) {\n /**\n * Resolve physics before choosing between physics- and duration-based\n * resolution, so an invalid stiffness doesn't also silently discard a\n * valid duration/bounce.\n */\n const validStiffness = resolvePhysics(options.stiffness)\n const validDamping = resolvePhysics(options.damping, true)\n const validMass = resolvePhysics(options.mass)\n\n const springOptions = {\n ...options,\n stiffness: validStiffness ?? defaultStiffness,\n damping: validDamping ?? defaultDamping,\n mass: validMass ?? defaultMass,\n isResolvedFromDuration: false,\n // stiffness/damping/mass overrides duration/bounce\n isTimeDefined:\n (validStiffness ?? validDamping ?? validMass) === undefined &&\n (options.duration !== undefined || options.bounce !== undefined),\n }\n\n if (springOptions.isTimeDefined) {\n if (options.visualDuration) {\n const dampingRatio = bounceToDampingRatio(options.bounce || 0)\n const root =\n ((2 * Math.PI) / (options.visualDuration * 1.2)) *\n overdampedFreqScale(dampingRatio, (2 * Math.PI) / 1.2)\n springOptions.stiffness = root * root\n springOptions.damping =\n 2 * dampingRatio * Math.sqrt(springOptions.stiffness)\n } else {\n Object.assign(springOptions, findSpring(springOptions))\n springOptions.isResolvedFromDuration = true\n }\n\n /**\n * Time options can degenerate: a NaN bounce gives a NaN damping, an\n * infinite visualDuration a 0 stiffness, and findSpring NaN for both\n * when it doesn't converge. Replace the two together, so the\n * relationship duration resolution establishes between them is never\n * left half-overwritten.\n */\n if (\n !isValidPhysics(springOptions.stiffness) ||\n !isValidPhysics(springOptions.damping, true)\n ) {\n springOptions.stiffness = defaultStiffness\n springOptions.damping = defaultDamping\n }\n }\n\n return springOptions\n}\n\nfunction springGenerator(\n optionsOrVisualDuration:\n | ValueAnimationOptions<number>\n | number = defaultVisualDuration,\n bounce = defaultBounce\n): KeyframeGenerator<number> {\n const options =\n typeof optionsOrVisualDuration !== \"object\"\n ? ({\n visualDuration: optionsOrVisualDuration,\n keyframes: [0, 1],\n bounce,\n } as ValueAnimationOptions<number>)\n : optionsOrVisualDuration\n\n const origin = options.keyframes[0]\n const target = options.keyframes[options.keyframes.length - 1]\n\n /**\n * This is the Iterator-spec return value. We ensure it's mutable rather than using a generator\n * to reduce GC during animation.\n */\n const state: AnimationState<number> = { done: false, value: origin }\n\n const {\n stiffness,\n damping,\n mass,\n duration,\n isResolvedFromDuration,\n isTimeDefined,\n } = getSpringOptions({ ...options })\n\n /**\n * A duration spring must end exactly at its duration, and it's settled\n * from rest by then. Inherited velocity could leave it still moving, so\n * it starts from rest. Every other spring, visualDuration included, ends\n * when it comes to rest, so inherits velocity as its initial condition.\n */\n const inheritVelocity = (velocity: number) =>\n isResolvedFromDuration ? 0 : -millisecondsToSeconds(velocity)\n\n const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass))\n const undampedAngularFreq = millisecondsToSeconds(\n Math.sqrt(stiffness / mass)\n )\n const decay = dampingRatio * undampedAngularFreq\n\n /**\n * Everything that changes when the spring is retargeted: written by\n * retarget() and update(), read by the resolvers. Grouped on one object,\n * like the coefficients (c) below. Writing doubles to object fields\n * measured marginally faster than to captured let variables in optimised\n * code; neither allocates, so this is a grouping choice, not a GC one.\n */\n const s = {\n target,\n delta: target - origin,\n velocity: inheritVelocity(options.velocity!) || 0,\n restSpeed: 0,\n restDelta: 0,\n }\n\n /**\n * If we're working on a granular scale, use smaller defaults for determining\n * when the spring is finished.\n *\n * These defaults have been selected empirically based on what strikes a good\n * ratio between feeling good and finishing as soon as changes are imperceptible.\n */\n const setRestThresholds = () => {\n const isGranularScale = Math.abs(s.delta) < 5\n s.restSpeed =\n options.restSpeed ||\n (isGranularScale ? restSpeedGranular : restSpeedDefault)\n s.restDelta =\n options.restDelta ||\n (isGranularScale ? restDeltaGranular : restDeltaDefault)\n }\n setRestThresholds()\n\n let resolveSpring: (v: number) => number\n let resolveVelocity: (t: number) => number\n\n /**\n * Derives the coefficients that depend on origin, target and initial\n * velocity. Called once now and again whenever the spring is retargeted.\n */\n let update: VoidFunction\n\n if (dampingRatio < 1) {\n const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio)\n\n /**\n * A is the position coefficient, sinC/cosC the coefficients of the\n * analytical derivative (px/ms). The exp/sin/cos terms depend only\n * on t, so they're memoized by t independently of the target: a\n * spring retargeted every frame samples the same t each frame and\n * skips the transcendentals entirely.\n */\n const c = { A: 0, sinC: 0, cosC: 0, t: -1, env: 0, sin: 0, cos: 0 }\n\n update = () => {\n c.A = (s.velocity + decay * s.delta) / angularFreq\n c.sinC = decay * c.A + s.delta * angularFreq\n c.cosC = decay * s.delta - c.A * angularFreq\n }\n\n const sample = (t: number) => {\n if (t !== c.t) {\n c.t = t\n c.env = Math.exp(-decay * t)\n c.sin = Math.sin(angularFreq * t)\n c.cos = Math.cos(angularFreq * t)\n }\n }\n\n // Underdamped spring\n resolveSpring = (t: number) => {\n sample(t)\n return s.target - c.env * (c.A * c.sin + s.delta * c.cos)\n }\n\n resolveVelocity = (t: number) => {\n sample(t)\n return c.env * (c.sinC * c.sin + c.cosC * c.cos)\n }\n } else if (dampingRatio === 1) {\n // Critically damped spring\n resolveSpring = (t: number) =>\n s.target -\n Math.exp(-undampedAngularFreq * t) *\n (s.delta + (s.velocity + undampedAngularFreq * s.delta) * t)\n\n // Analytical derivative of critically damped spring (px/ms)\n const c = { C: 0 }\n update = () => {\n c.C = s.velocity + undampedAngularFreq * s.delta\n }\n resolveVelocity = (t: number) =>\n Math.exp(-undampedAngularFreq * t) *\n (undampedAngularFreq * c.C * t - s.velocity)\n } else {\n /**\n * Overdamped spring: the sum of a slow and a fast decaying\n * exponential, so no term can overflow however heavily it's damped.\n */\n const dampedAngularFreq =\n undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1)\n const slow = decay - dampedAngularFreq\n const fast = decay + dampedAngularFreq\n\n /**\n * Physics-defined springs keep a non-physical limit: once\n * dampedAngularFreq * t passes 300, both terms decay at the damping\n * rate. Heavily overdamped drag springs (dragElastic: 0,\n * dragTransition) rely on this to settle almost at once rather than\n * creep at stiffness / damping. It only applies when reached within\n * 300ms (a dampedAngularFreq of 1 rad/ms), so it reads as a stiff\n * spring snapping into place: any later and it cuts off a slow spring\n * that's visibly still moving (#1207). Negative bounce needs the\n * exact curve, so time-defined springs are exempt.\n */\n const limit =\n dampedAngularFreq < 1 || isTimeDefined\n ? Infinity\n : 300 / dampedAngularFreq\n const decayAt = (rate: number, t: number) =>\n Math.exp(t > limit ? (decay - rate) * limit - decay * t : -rate * t)\n\n const c = { S: 0, F: 0 }\n update = () => {\n const P = (s.velocity + decay * s.delta) / dampedAngularFreq\n c.S = (s.delta + P) / 2\n c.F = (s.delta - P) / 2\n }\n\n resolveSpring = (t: number) =>\n s.target - c.S * decayAt(slow, t) - c.F * decayAt(fast, t)\n\n // Analytical derivative of overdamped spring (px/ms)\n resolveVelocity = (t: number) =>\n slow * c.S * decayAt(slow, t) + fast * c.F * decayAt(fast, t)\n }\n\n update()\n\n const calculatedDuration = isResolvedFromDuration ? duration || null : null\n\n const generator = {\n calculatedDuration,\n /**\n * Aim the spring at a new target from its current position and\n * velocity, reusing the resolved physics and closures.\n */\n retarget: (keyframes: number[], newVelocity: number) => {\n s.target = keyframes[keyframes.length - 1]\n s.delta = s.target - keyframes[0]\n s.velocity = inheritVelocity(newVelocity)\n // Default thresholds depend on the scale of the new delta\n if (!(options.restSpeed && options.restDelta)) setRestThresholds()\n // Invalidate any duration lazily cached by JSAnimation\n generator.calculatedDuration = calculatedDuration\n state.done = false\n update()\n },\n velocity: (t: number) => secondsToMilliseconds(resolveVelocity(t)),\n next: (t: number) => {\n const current = resolveSpring(t)\n\n if (!isResolvedFromDuration) {\n const currentVelocity = secondsToMilliseconds(\n resolveVelocity(t)\n )\n state.done =\n Math.abs(currentVelocity) <= s.restSpeed &&\n Math.abs(s.target - current) <= s.restDelta\n } else {\n state.done = t >= duration!\n }\n\n state.value = state.done ? s.target : current\n\n return state\n },\n toString: () => {\n const easingDuration = Math.min(\n calcGeneratorDuration(generator),\n maxGeneratorDuration\n )\n\n const easing = generateLinearEasing(\n (progress: number) =>\n generator.next(easingDuration * progress).value,\n easingDuration,\n 30\n )\n\n return easingDuration + \"ms \" + easing\n },\n }\n\n return generator\n}\n\nconst spring = /* @__PURE__ */ Object.assign(springGenerator, {\n applyToOptions: (options: Transition) => {\n const generatorOptions = createGeneratorEasing(\n options as any,\n 100,\n springGenerator\n )\n\n options.ease = generatorOptions.ease\n options.duration = secondsToMilliseconds(generatorOptions.duration)\n options.type = \"keyframes\"\n return options\n },\n})\n\nexport { spring }\n"],"names":[],"mappings":";;;;;AAoBA;AACA,MAAM,gBAAgB,GAAG,GAAG;AAC5B,MAAM,cAAc,GAAG,EAAE;AACzB,MAAM,WAAW,GAAG,GAAG;AAEvB;AACA,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,aAAa,GAAG,GAAG;AACzB,MAAM,qBAAqB,GAAG,GAAG,CAAA;AAEjC;AACA,MAAM,iBAAiB,GAAG,IAAI;AAC9B,MAAM,gBAAgB,GAAG,CAAC;AAC1B,MAAM,iBAAiB,GAAG,KAAK;AAC/B,MAAM,gBAAgB,GAAG,GAAG;AAE5B;AACA,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,UAAU,GAAG,IAAI;AAEvB;;;;AAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAAc,KACxC,MAAM,GAAG;AACL,MAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,UAAU;MACnC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC;AAE1C;;;;;;;;;;AAUG;AACH,SAAS,mBAAmB,CAAC,YAAoB,EAAE,gBAAwB,EAAA;AACvE,IAAA,IAAI,EAAE,YAAY,GAAG,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC;AAEjC,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,YAAY,GAAG,CAAC,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AC3B,qBAAqB,CAAC,SAAS,CAAC,EAChC,oBAAoB,CACvB;YAED,MAAM,MAAM,GAAG,oBAAoB,CAC/B,CAAC,QAAgB,KACb,SAAS,CAAC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,CAAC,KAAK,EACnD,cAAc,EACd,EAAE,CACL;AAED,YAAA,OAAO,cAAc,GAAG,KAAK,GAAG,MAAM;QAC1C,CAAC;KACJ;AAED,IAAA,OAAO,SAAS;AACpB;AAEA,MAAM,MAAM,mBAAmB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;AAC1D,IAAA,cAAc,EAAE,CAAC,OAAmB,KAAI;QACpC,MAAM,gBAAgB,GAAG,qBAAqB,CAC1C,OAAc,EACd,GAAG,EACH,eAAe,CAClB;AAED,QAAA,OAAO,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI;QACpC,OAAO,CAAC,QAAQ,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AACnE,QAAA,OAAO,CAAC,IAAI,GAAG,WAAW;AAC1B,QAAA,OAAO,OAAO;IAClB,CAAC;AACJ,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"spring.mjs","sources":["../../../../src/animation/generators/spring.ts"],"sourcesContent":["import {\n clamp,\n millisecondsToSeconds,\n secondsToMilliseconds,\n warning,\n} from \"motion-utils\"\nimport {\n AnimationState,\n KeyframeGenerator,\n SpringOptions,\n Transition,\n ValueAnimationOptions,\n} from \"../types\"\nimport { generateLinearEasing } from \"../waapi/utils/linear\"\nimport {\n calcGeneratorDuration,\n maxGeneratorDuration,\n} from \"./utils/calc-duration\"\nimport { createGeneratorEasing } from \"./utils/create-generator-easing\"\n\n// Default spring physics\nconst defaultStiffness = 100\nconst defaultDamping = 10\nconst defaultMass = 1.0\n\n// Default duration/bounce-based options\nconst defaultDuration = 800 // in ms\nconst defaultBounce = 0.3\nconst defaultVisualDuration = 0.3 // in seconds\n\n// Rest thresholds\nconst restSpeedGranular = 0.01\nconst restSpeedDefault = 2\nconst restDeltaGranular = 0.005\nconst restDeltaDefault = 0.5\n\n// Limits\nconst minDuration = 0.01 // in seconds\nconst maxDuration = 10.0 // in seconds\nconst minDamping = 0.05\n\n/**\n * Maps bounce to a damping ratio as SwiftUI does: 0 is critically damped, and\n * it approaches undamped towards 1 and infinitely overdamped towards -1. Both\n * ends are limited so the spring still moves and settles.\n */\nconst bounceToDampingRatio = (bounce: number) =>\n bounce < 0\n ? 1 / Math.max(1 + bounce, minDamping)\n : Math.max(1 - bounce, minDamping)\n\n/**\n * Scales an overdamped spring's undamped frequency so that, at its defining\n * time, it has as far left to go as the critically damped spring that's\n * criticalFreqTime radians in by then. A negative bounce then changes the\n * shape of the curve, not when it arrives. 1 at a damping ratio of 1, so\n * there's no jump at a bounce of 0.\n *\n * Solved by Newton on the remaining distance (times fast - slow), which is\n * convex from criticalFreqTime onwards. criticalFreqTime is always below the\n * answer, so it converges from below without overshooting.\n */\nfunction overdampedFreqScale(dampingRatio: number, criticalFreqTime: number) {\n if (!(dampingRatio > 1)) return 1\n\n const root = Math.sqrt(dampingRatio * dampingRatio - 1)\n const slow = dampingRatio - root\n const fast = dampingRatio + root\n const target =\n 2 * root * Math.exp(-criticalFreqTime) * (1 + criticalFreqTime)\n\n return (\n approximateRoot(\n (freqTime) =>\n fast * Math.exp(-slow * freqTime) -\n slow * Math.exp(-fast * freqTime) -\n target,\n (freqTime) =>\n Math.exp(-fast * freqTime) - Math.exp(-slow * freqTime),\n criticalFreqTime\n ) / criticalFreqTime\n )\n}\n\nfunction calcAngularFreq(undampedFreq: number, dampingRatio: number) {\n return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio)\n}\n\nconst rootIterations = 12\nfunction approximateRoot(\n envelope: (num: number) => number,\n derivative: (num: number) => number,\n initialGuess: number\n): number {\n let result = initialGuess\n for (let i = 1; i < rootIterations; i++) {\n result = result - envelope(result) / derivative(result)\n }\n return result\n}\n\n/**\n * This is ported from the Framer implementation of duration-based spring resolution.\n */\nconst safeMin = 0.001\n\n/**\n * Assumes zero initial velocity and the default mass: duration springs start\n * from rest so they end exactly at their duration. Only resolves without\n * valid physics. Returns NaN physics when the root search doesn't converge.\n */\nfunction findSpring({\n duration = defaultDuration,\n bounce = defaultBounce,\n}: SpringOptions) {\n let envelope: (num: number) => number\n let derivative: (num: number) => number\n\n process.env.NODE_ENV !== \"production\" &&\n warning(\n duration <= secondsToMilliseconds(maxDuration),\n \"Spring duration must be 10 seconds or less\",\n \"spring-duration-limit\"\n )\n\n const dampingRatio = bounceToDampingRatio(bounce)\n\n duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration))\n\n if (dampingRatio < 1) {\n /**\n * Underdamped spring\n */\n envelope = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio\n const delta = exponentialDecay * duration\n const b = calcAngularFreq(undampedFreq, dampingRatio)\n const c = Math.exp(-delta)\n return safeMin - (exponentialDecay / b) * c\n }\n\n derivative = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio\n const delta = exponentialDecay * duration\n const e =\n dampingRatio *\n dampingRatio *\n undampedFreq *\n undampedFreq *\n duration\n const f = Math.exp(-delta)\n const g = calcAngularFreq(undampedFreq * undampedFreq, dampingRatio)\n const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1\n return (factor * -e * f) / g\n }\n } else {\n /**\n * Critically-damped spring. Overdamped springs reuse this root,\n * scaled below.\n */\n envelope = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration)\n const b = undampedFreq * duration + 1\n return -safeMin + a * b\n }\n\n derivative = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration)\n const b = -undampedFreq * (duration * duration)\n return a * b\n }\n }\n\n const initialGuess = 5 / duration\n const criticalFreq = approximateRoot(envelope, derivative, initialGuess)\n const undampedFreq =\n criticalFreq *\n overdampedFreqScale(dampingRatio, criticalFreq * duration)\n const stiffness = undampedFreq * undampedFreq\n\n return {\n stiffness,\n damping: dampingRatio * 2 * Math.sqrt(stiffness),\n duration: secondsToMilliseconds(duration),\n }\n}\n\n/**\n * Spring physics must be finite. stiffness and mass are also divisors so must\n * be positive, whereas a damping of 0 is a valid, perpetually oscillating\n * spring. Relational rather than Number.isFinite so numeric strings still\n * coerce.\n */\nconst isValidPhysics = (value: number | undefined, canBeZero?: boolean) =>\n (canBeZero ? value! >= 0 : value! > 0) && value! < Infinity\n\n/**\n * Returns value if it's usable spring physics, otherwise undefined so callers\n * fall back to the default. An explicit `undefined`, e.g. from a forwarded\n * optional prop, must fall back too. Invalid physics would otherwise resolve\n * to NaN spring values that never report done.\n */\nfunction resolvePhysics(value: number | undefined, canBeZero?: boolean) {\n if (isValidPhysics(value, canBeZero)) return value\n\n if (process.env.NODE_ENV !== \"production\") {\n warning(\n value === undefined || (value as unknown) === \"auto\",\n \"Spring stiffness and mass must be positive, damping 0 or greater\",\n \"spring-invalid-physics\"\n )\n }\n\n return undefined\n}\n\nexport function getSpringOptions(options: SpringOptions) {\n /**\n * Resolve physics before choosing between physics- and duration-based\n * resolution, so an invalid stiffness doesn't also silently discard a\n * valid duration/bounce.\n */\n const validStiffness = resolvePhysics(options.stiffness)\n const validDamping = resolvePhysics(options.damping, true)\n const validMass = resolvePhysics(options.mass as number)\n\n const springOptions = {\n ...options,\n stiffness: validStiffness ?? defaultStiffness,\n damping: validDamping ?? defaultDamping,\n mass: validMass ?? defaultMass,\n isResolvedFromDuration: false,\n // stiffness/damping/mass overrides duration/bounce\n isTimeDefined:\n (validStiffness ?? validDamping ?? validMass) === undefined &&\n (options.duration !== undefined || options.bounce !== undefined),\n }\n\n if (springOptions.isTimeDefined) {\n if (options.visualDuration) {\n const dampingRatio = bounceToDampingRatio(options.bounce || 0)\n const root =\n ((2 * Math.PI) / (options.visualDuration * 1.2)) *\n overdampedFreqScale(dampingRatio, (2 * Math.PI) / 1.2)\n springOptions.stiffness = root * root\n springOptions.damping =\n 2 * dampingRatio * Math.sqrt(springOptions.stiffness)\n } else {\n Object.assign(springOptions, findSpring(springOptions))\n springOptions.isResolvedFromDuration = true\n }\n\n /**\n * Time options can degenerate: a NaN bounce gives a NaN damping, an\n * infinite visualDuration a 0 stiffness, and findSpring NaN for both\n * when it doesn't converge. Replace the two together, so the\n * relationship duration resolution establishes between them is never\n * left half-overwritten.\n */\n if (\n !isValidPhysics(springOptions.stiffness) ||\n !isValidPhysics(springOptions.damping, true)\n ) {\n springOptions.stiffness = defaultStiffness\n springOptions.damping = defaultDamping\n }\n }\n\n return springOptions\n}\n\nfunction springGenerator(\n optionsOrVisualDuration:\n | ValueAnimationOptions<number>\n | number = defaultVisualDuration,\n bounce = defaultBounce\n): KeyframeGenerator<number> {\n const options =\n typeof optionsOrVisualDuration !== \"object\"\n ? ({\n visualDuration: optionsOrVisualDuration,\n keyframes: [0, 1],\n bounce,\n } as ValueAnimationOptions<number>)\n : optionsOrVisualDuration\n\n const origin = options.keyframes[0]\n const target = options.keyframes[options.keyframes.length - 1]\n\n /**\n * This is the Iterator-spec return value. We ensure it's mutable rather than using a generator\n * to reduce GC during animation.\n */\n const state: AnimationState<number> = { done: false, value: origin }\n\n const {\n stiffness,\n damping,\n mass,\n duration,\n isResolvedFromDuration,\n isTimeDefined,\n } = getSpringOptions({ ...options })\n\n /**\n * A duration spring must end exactly at its duration, and it's settled\n * from rest by then. Inherited velocity could leave it still moving, so\n * it starts from rest. Every other spring, visualDuration included, ends\n * when it comes to rest, so inherits velocity as its initial condition.\n */\n const inheritVelocity = (velocity: number) =>\n isResolvedFromDuration ? 0 : -millisecondsToSeconds(velocity)\n\n const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass))\n const undampedAngularFreq = millisecondsToSeconds(\n Math.sqrt(stiffness / mass)\n )\n const decay = dampingRatio * undampedAngularFreq\n\n /**\n * Everything that changes when the spring is retargeted: written by\n * retarget() and update(), read by the resolvers. Grouped on one object,\n * like the coefficients (c) below. Writing doubles to object fields\n * measured marginally faster than to captured let variables in optimised\n * code; neither allocates, so this is a grouping choice, not a GC one.\n */\n const s = {\n target,\n delta: target - origin,\n velocity: inheritVelocity(options.velocity!) || 0,\n restSpeed: 0,\n restDelta: 0,\n }\n\n /**\n * If we're working on a granular scale, use smaller defaults for determining\n * when the spring is finished.\n *\n * These defaults have been selected empirically based on what strikes a good\n * ratio between feeling good and finishing as soon as changes are imperceptible.\n */\n const setRestThresholds = () => {\n const isGranularScale = Math.abs(s.delta) < 5\n s.restSpeed =\n options.restSpeed ||\n (isGranularScale ? restSpeedGranular : restSpeedDefault)\n s.restDelta =\n options.restDelta ||\n (isGranularScale ? restDeltaGranular : restDeltaDefault)\n }\n setRestThresholds()\n\n let resolveSpring: (v: number) => number\n let resolveVelocity: (t: number) => number\n\n /**\n * Derives the coefficients that depend on origin, target and initial\n * velocity. Called once now and again whenever the spring is retargeted.\n */\n let update: VoidFunction\n\n if (dampingRatio < 1) {\n const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio)\n\n /**\n * A is the position coefficient, sinC/cosC the coefficients of the\n * analytical derivative (px/ms). The exp/sin/cos terms depend only\n * on t, so they're memoized by t independently of the target: a\n * spring retargeted every frame samples the same t each frame and\n * skips the transcendentals entirely.\n */\n const c = { A: 0, sinC: 0, cosC: 0, t: -1, env: 0, sin: 0, cos: 0 }\n\n update = () => {\n c.A = (s.velocity + decay * s.delta) / angularFreq\n c.sinC = decay * c.A + s.delta * angularFreq\n c.cosC = decay * s.delta - c.A * angularFreq\n }\n\n const sample = (t: number) => {\n if (t !== c.t) {\n c.t = t\n c.env = Math.exp(-decay * t)\n c.sin = Math.sin(angularFreq * t)\n c.cos = Math.cos(angularFreq * t)\n }\n }\n\n // Underdamped spring\n resolveSpring = (t: number) => {\n sample(t)\n return s.target - c.env * (c.A * c.sin + s.delta * c.cos)\n }\n\n resolveVelocity = (t: number) => {\n sample(t)\n return c.env * (c.sinC * c.sin + c.cosC * c.cos)\n }\n } else if (dampingRatio === 1) {\n // Critically damped spring\n resolveSpring = (t: number) =>\n s.target -\n Math.exp(-undampedAngularFreq * t) *\n (s.delta + (s.velocity + undampedAngularFreq * s.delta) * t)\n\n // Analytical derivative of critically damped spring (px/ms)\n const c = { C: 0 }\n update = () => {\n c.C = s.velocity + undampedAngularFreq * s.delta\n }\n resolveVelocity = (t: number) =>\n Math.exp(-undampedAngularFreq * t) *\n (undampedAngularFreq * c.C * t - s.velocity)\n } else {\n /**\n * Overdamped spring: the sum of a slow and a fast decaying\n * exponential, so no term can overflow however heavily it's damped.\n */\n const dampedAngularFreq =\n undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1)\n const slow = decay - dampedAngularFreq\n const fast = decay + dampedAngularFreq\n\n /**\n * Physics-defined springs keep a non-physical limit: once\n * dampedAngularFreq * t passes 300, both terms decay at the damping\n * rate. Heavily overdamped drag springs (dragElastic: 0,\n * dragTransition) rely on this to settle almost at once rather than\n * creep at stiffness / damping. It only applies when reached within\n * 300ms (a dampedAngularFreq of 1 rad/ms), so it reads as a stiff\n * spring snapping into place: any later and it cuts off a slow spring\n * that's visibly still moving (#1207). Negative bounce needs the\n * exact curve, so time-defined springs are exempt.\n */\n const limit =\n dampedAngularFreq < 1 || isTimeDefined\n ? Infinity\n : 300 / dampedAngularFreq\n const decayAt = (rate: number, t: number) =>\n Math.exp(t > limit ? (decay - rate) * limit - decay * t : -rate * t)\n\n const c = { S: 0, F: 0 }\n update = () => {\n const P = (s.velocity + decay * s.delta) / dampedAngularFreq\n c.S = (s.delta + P) / 2\n c.F = (s.delta - P) / 2\n }\n\n resolveSpring = (t: number) =>\n s.target - c.S * decayAt(slow, t) - c.F * decayAt(fast, t)\n\n // Analytical derivative of overdamped spring (px/ms)\n resolveVelocity = (t: number) =>\n slow * c.S * decayAt(slow, t) + fast * c.F * decayAt(fast, t)\n }\n\n update()\n\n const calculatedDuration = isResolvedFromDuration ? duration || null : null\n\n const generator = {\n calculatedDuration,\n /**\n * Aim the spring at a new target from its current position and\n * velocity, reusing the resolved physics and closures.\n */\n retarget: (keyframes: number[], newVelocity: number) => {\n s.target = keyframes[keyframes.length - 1]\n s.delta = s.target - keyframes[0]\n s.velocity = inheritVelocity(newVelocity)\n // Default thresholds depend on the scale of the new delta\n if (!(options.restSpeed && options.restDelta)) setRestThresholds()\n // Invalidate any duration lazily cached by JSAnimation\n generator.calculatedDuration = calculatedDuration\n state.done = false\n update()\n },\n velocity: (t: number) => secondsToMilliseconds(resolveVelocity(t)),\n next: (t: number) => {\n const current = resolveSpring(t)\n\n if (!isResolvedFromDuration) {\n const currentVelocity = secondsToMilliseconds(\n resolveVelocity(t)\n )\n state.done =\n Math.abs(currentVelocity) <= s.restSpeed &&\n Math.abs(s.target - current) <= s.restDelta\n } else {\n state.done = t >= duration!\n }\n\n state.value = state.done ? s.target : current\n\n return state\n },\n toString: () => {\n const easingDuration = Math.min(\n calcGeneratorDuration(generator),\n maxGeneratorDuration\n )\n\n const easing = generateLinearEasing(\n (progress: number) =>\n generator.next(easingDuration * progress).value,\n easingDuration,\n 30\n )\n\n return easingDuration + \"ms \" + easing\n },\n }\n\n return generator\n}\n\nconst spring = /* @__PURE__ */ Object.assign(springGenerator, {\n applyToOptions: (options: Transition) => {\n const generatorOptions = createGeneratorEasing(\n options as any,\n 100,\n springGenerator\n )\n\n options.ease = generatorOptions.ease\n options.duration = secondsToMilliseconds(generatorOptions.duration)\n options.type = \"keyframes\"\n return options\n },\n})\n\nexport { spring }\n"],"names":[],"mappings":";;;;;AAoBA;AACA,MAAM,gBAAgB,GAAG,GAAG;AAC5B,MAAM,cAAc,GAAG,EAAE;AACzB,MAAM,WAAW,GAAG,GAAG;AAEvB;AACA,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,aAAa,GAAG,GAAG;AACzB,MAAM,qBAAqB,GAAG,GAAG,CAAA;AAEjC;AACA,MAAM,iBAAiB,GAAG,IAAI;AAC9B,MAAM,gBAAgB,GAAG,CAAC;AAC1B,MAAM,iBAAiB,GAAG,KAAK;AAC/B,MAAM,gBAAgB,GAAG,GAAG;AAE5B;A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,QAAA,OAAO,OAAO;IAClB,CAAC;AACJ,CAAA;;;;"}
|
|
@@ -232,15 +232,14 @@ function addPinchListeners(element, getValues, getEnabledOptions, onPinchStart)
|
|
|
232
232
|
* step and the focal point stays in place.
|
|
233
233
|
*/
|
|
234
234
|
const tick = () => {
|
|
235
|
-
if (dragControls()?.isDragging)
|
|
236
|
-
return stopSnap();
|
|
237
235
|
const { value: p, done } = generator.next(time.now() - startTime);
|
|
238
236
|
if (done)
|
|
239
237
|
stopSnap();
|
|
240
238
|
const [k, r, fx, fy] = at(p);
|
|
241
239
|
scaleOption !== false && scale.set(k);
|
|
242
240
|
rotateOption !== false && rotate.set(r);
|
|
243
|
-
|
|
241
|
+
// A drag that starts mid-snap owns x/y from then on.
|
|
242
|
+
if (moves && !dragControls()?.isDragging) {
|
|
244
243
|
x.set(snapToOrigin ? mixNumber(x0, 0, p) : fx);
|
|
245
244
|
y.set(snapToOrigin ? mixNumber(y0, 0, p) : fy);
|
|
246
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/pinch/index.ts"],"sourcesContent":["import { clamp, type Point } from \"motion-utils\"\nimport { spring } from \"../../animation/generators/spring\"\nimport type { SpringOptions } from \"../../animation/types\"\nimport { readStyleValue, styleSubjectEffect } from \"../../effects/style\"\nimport { svgSubjectEffect } from \"../../effects/svg\"\nimport { cancelFrame, frame } from \"../../frameloop\"\nimport { time } from \"../../frameloop/sync-time\"\nimport { visualElementStore } from \"../../render/store\"\nimport { activeScope, addToScope } from \"../../scope/active\"\nimport { isSVGElement } from \"../../utils/is-svg-element\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../../utils/resolve-elements\"\nimport { motionValue, type MotionValue } from \"../../value\"\nimport { setDragLock } from \"../drag/state/set-active\"\nimport { applyConstraints, defaultElastic } from \"../drag/utils/constraints\"\nimport { elementDragControls } from \"../drag/VisualElementDragControls\"\n\n/**\n * @public\n */\nexport interface PinchInfo {\n /**\n * The gesture's focal point in client coordinates: the midpoint\n * between two touches, or the cursor for a trackpad pinch.\n */\n point: Point\n\n /**\n * How far the focal point has moved since the gesture started.\n */\n offset: Point\n\n /**\n * The gesture's scale relative to its start.\n */\n scale: number\n\n /**\n * The gesture's rotation since its start, in degrees.\n */\n rotate: number\n}\n\n/**\n * Called with the latest event and the gesture's info.\n *\n * @public\n */\nexport type OnPinchEvent = (event: Event, info: PinchInfo) => void\n\n/**\n * Handlers for a single pinch gesture, returned from the pinch start\n * callback.\n *\n * @public\n */\nexport interface PinchHandlers {\n /**\n * Called each frame the gesture changes, after the element's values\n * are updated.\n */\n onPinch?: OnPinchEvent\n\n /**\n * Called once when the gesture ends: a touch lifts or is cancelled, a\n * trackpad pinch stops, or the gesture is disabled or removed.\n *\n * Returning this function directly from the pinch start callback is\n * equivalent.\n */\n onComplete?: OnPinchEvent\n}\n\n/**\n * Called once when a pinch gesture starts: when a second touch lands, on\n * the first trackpad pinch event, or on Safari's `gesturestart`. Can\n * return a function to call when the pinch ends, or an object of\n * `PinchHandlers`.\n *\n * @public\n */\nexport type OnPinchStartEvent = (\n element: Element,\n event: Event\n) => OnPinchEvent | PinchHandlers | void\n\n/**\n * The limits of a pinch's scale or rotation.\n *\n * @public\n */\nexport interface PinchLimits {\n /**\n * The minimum. Past it, the gesture resists by `elastic`, and the\n * value springs back to it on release.\n */\n min?: number\n\n /**\n * The maximum. Past it, the gesture resists by `elastic`, and the\n * value springs back to it on release.\n */\n max?: number\n}\n\n/**\n * @public\n */\nexport interface PinchRotateOptions extends PinchLimits {\n /**\n * On release, rotate to the nearest multiple of this many degrees.\n */\n snap?: number\n}\n\n/**\n * @public\n */\nexport interface PinchOptions {\n /**\n * Scale the element. Defaults to `true`. Pass `{ min, max }` to limit\n * the scale.\n */\n scale?: boolean | PinchLimits\n\n /**\n * Rotate the element with the touches. Defaults to `true`. Pass\n * `{ min, max }` (in degrees) to limit the rotation, and `snap` to\n * rotate to the nearest multiple of `snap` degrees on release.\n */\n rotate?: boolean | PinchRotateOptions\n\n /**\n * Move the element with the focal point, and keep the point under the\n * fingers (or cursor) in place while scaling and rotating. Defaults to\n * `true`. Composes with drag: a drag that one of the touches started\n * carries on from wherever the pinch leaves the element (its offset\n * restarts there). Drag constraints aren't applied while pinching.\n *\n * Assumes the default `transform-origin` (the element's centre).\n */\n pan?: boolean\n\n /**\n * The point that scale and rotation pivot around. `\"pointer\"` (the\n * default) is the focal point between the touches, or the cursor.\n * `{ x, y }` is a point on the element, as a fraction of its width\n * and height: `{ x: 0.5, y: 0.5 }` is its centre. With `pan: false`,\n * the default is the centre.\n */\n origin?: \"pointer\" | Point\n\n /**\n * How far scale and rotation can go past their limits, as for\n * `dragElastic`: `0` stops at the limit, `1` doesn't resist. Pass\n * `{ min, max }` to set each side. Defaults to `0.35`.\n */\n elastic?: boolean | number | PinchLimits\n\n /**\n * On release, animate scale back to `1`, and rotation and `x`/`y`\n * back to `0`.\n */\n snapToOrigin?: boolean\n\n /**\n * The spring values use to animate back inside their limits, to a\n * `snap` angle or to their origin.\n */\n transition?: SpringOptions\n}\n\n/**\n * Options for the `pinch` prop.\n *\n * @public\n */\nexport interface PinchProps extends PinchOptions {\n /**\n * Called when the pinch starts.\n */\n onStart?: OnPinchEvent\n\n /**\n * Called each frame the pinch changes.\n */\n onMove?: OnPinchEvent\n\n /**\n * Called when the pinch ends.\n */\n onEnd?: OnPinchEvent\n}\n\nexport type PinchValues = [\n scale: MotionValue<number>,\n rotate: MotionValue<number>,\n x: MotionValue<number>,\n y: MotionValue<number>,\n]\n\n/**\n * A trackpad pinch arrives as a stream of `wheel` events with no end\n * event, so it ends once none have arrived for this long.\n */\nconst wheelTimeout = 150\n\n/**\n * Convert an `x`/`y` set in other units (e.g. `\"-50%\"` to centre an\n * element) to pixels, so the gesture can add to it.\n */\nconst toPixels = (value: MotionValue<number>, size: number) => {\n const latest = value.get() as number | string\n\n if (typeof latest === \"string\") {\n value.set(parseFloat(latest) * (latest.endsWith(\"%\") ? size / 100 : 1))\n }\n}\n\nconst limitsOf = (option?: boolean | PinchRotateOptions): PinchRotateOptions =>\n typeof option === \"object\" ? option : {}\n\n/**\n * Resolve `elastic` to a resistance for each side, as for `dragElastic`.\n */\nconst resolveElastic = (\n elastic: PinchOptions[\"elastic\"] = defaultElastic\n): { min: number; max: number } => {\n const side = (value?: number | boolean) =>\n value === true ? defaultElastic : +(value || 0)\n\n return typeof elastic === \"object\"\n ? { min: side(elastic.min), max: side(elastic.max) }\n : { min: side(elastic), max: side(elastic) }\n}\n\n/**\n * Whether the gesture writes `x`/`y`: to follow the focal point, or to\n * keep an `origin` on the element in place.\n */\nconst writesXY = ({ pan, origin }: PinchOptions) => pan !== false || !!origin\n\nconst clampTo = (value: number, { min = -Infinity, max = Infinity }) =>\n clamp(min, max, value)\n\n/**\n * The raw gesture value that elastic shows as `value`. A pinch that starts\n * while a value is still past its limit (like during a spring back) carries\n * on from it, rather than jumping.\n */\nconst unconstrain = (\n value: number,\n option: boolean | PinchRotateOptions | undefined,\n resistance: { min: number; max: number }\n) => {\n const limit = clampTo(value, limitsOf(option))\n const elastic = resistance[value < limit ? \"min\" : \"max\"]\n\n return elastic ? limit + (value - limit) / elastic : value\n}\n\n/**\n * Listen for pinch gestures on `element`: two touches (or pens), a trackpad\n * pinch (`wheel` with `ctrlKey`, as Chrome, Edge and Firefox report it),\n * and Safari's `gesture*` events.\n *\n * `getValues` is called each time a gesture starts, in the frame's read\n * step, for the scale/rotate/x/y values to write to. It runs alongside the\n * element measurement so neither forces a layout.\n *\n * `getOptions` is read whenever it's needed, so options can change while\n * listening. Return `false` to disable the gesture, which also ends one in\n * progress.\n *\n * `onPinchStart` is called once as each gesture starts, with the gesture's\n * info as a third argument. It can return the gesture's handlers, as for\n * `pinch()`.\n */\nexport function addPinchListeners(\n element: Element,\n getValues: () => PinchValues,\n getEnabledOptions: () => PinchOptions | false | undefined,\n onPinchStart: (\n element: Element,\n event: Event,\n info: PinchInfo\n ) => ReturnType<OnPinchStartEvent>\n): VoidFunction {\n const pointers = new Map<number, Point>()\n\n /**\n * The gesture as last reported: focal point, log of a distance and an\n * angle. Only changes in distance and angle matter, so trackpad and\n * Safari input write a virtual distance (the scale) here. Logs keep\n * a long trackpad pinch from overflowing.\n */\n const current = { x: 0, y: 0, l: 0, a: 0 }\n const start = { ...current }\n const prev = { ...current }\n\n let source: \"pointer\" | \"wheel\" | \"gesture\" | undefined\n let lastEvent: Event\n let values: PinchValues | undefined\n let originX = 0\n let originY = 0\n let width = 0\n let height = 0\n let lastX = 0\n let lastY = 0\n let hasMoved = false\n let wheelTime = 0\n let handlers: PinchHandlers = {}\n let unlock: VoidFunction | null | undefined\n\n /**\n * The gesture's scale and rotation before limits and elastic apply.\n */\n let rawScale = 1\n let rawRotate = 0\n let stopSnap = () => {}\n\n /**\n * The latest enabled options, so a gesture disabled mid-way can still\n * report its end.\n */\n let options: PinchOptions = {}\n const getOptions = () => (options = getEnabledOptions() || options)\n\n const info = (): PinchInfo => ({\n point: { x: current.x, y: current.y },\n offset: { x: current.x - start.x, y: current.y - start.y },\n scale: Math.exp(current.l - start.l),\n rotate: current.a - start.a,\n })\n\n /**\n * Read the element's box and values, and find its layout origin: its\n * centre without `x`/`y`. Scale and rotate are applied around the\n * centre (the default transform origin), so they don't move it.\n */\n const measure = () => {\n const box = element.getBoundingClientRect()\n const { left, top } = box\n const { scale, rotate, elastic } = getOptions()\n const [s, r, x, y] = (values = getValues())\n const resistance = resolveElastic(elastic)\n\n /**\n * Stop animations on values this gesture writes, and leave the\n * rest running.\n */\n scale !== false && s.stop()\n rotate !== false && r.stop()\n rawScale = unconstrain(s.get(), scale, resistance)\n rawRotate = unconstrain(r.get(), rotate, resistance)\n\n width = (element as HTMLElement).offsetWidth ?? box.width\n height = (element as HTMLElement).offsetHeight ?? box.height\n\n if (writesXY(options)) {\n x.stop()\n y.stop()\n toPixels(x, width)\n toPixels(y, height)\n }\n\n lastX = x.get()\n lastY = y.get()\n originX = left + box.width / 2 - lastX\n originY = top + box.height / 2 - lastY\n }\n\n /**\n * The point scale and rotation pivot around, in client coordinates:\n * the focal point, or `origin` on the element at scale `s`, rotation\n * `r` and offset `x`/`y`.\n */\n const pivot = (\n focal: Point,\n s: number,\n r: number,\n x: number,\n y: number\n ): Point => {\n const { origin } = options\n if (typeof origin !== \"object\") return focal\n\n const a = (r * Math.PI) / 180\n const u = (origin.x - 0.5) * width * s\n const v = (origin.y - 0.5) * height * s\n\n return {\n x: originX + x + Math.cos(a) * u - Math.sin(a) * v,\n y: originY + y + Math.sin(a) * u + Math.cos(a) * v,\n }\n }\n\n const dragControls = () =>\n elementDragControls.get(visualElementStore.get(element)!)\n\n /**\n * On release, spring scale and rotation back inside their limits (or\n * to a `snap` angle), keeping the focal point in place, or everything\n * back to its origin with `snapToOrigin`.\n */\n const snap = () => {\n const {\n scale: scaleOption,\n rotate: rotateOption,\n snapToOrigin,\n transition,\n } = options\n const [scale, rotate, x, y] = values!\n const s0 = scale.get()\n const r0 = rotate.get()\n const x0 = x.get()\n const y0 = y.get()\n const { snap: step } = limitsOf(rotateOption)\n let s1 = clampTo(s0, limitsOf(scaleOption))\n /**\n * Snap to the step nearest where the release velocity would carry\n * the rotation, found as inertia finds its target (with a lower power\n * than inertia's 0.8).\n */\n let r1 = clampTo(\n step\n ? Math.round((r0 + 0.2 * rotate.getVelocity()) / step) * step\n : r0,\n limitsOf(rotateOption)\n )\n\n if (snapToOrigin) {\n s1 = 1\n // The nearest upright angle, so it turns the shortest way\n r1 = Math.round(r0 / 360) * 360\n }\n\n /**\n * Keep the focal point in place, unless the element doesn't move\n * with it, or a drag carries on and owns x/y.\n */\n const moves = writesXY(options) && !dragControls()?.isDragging\n const p0 = pivot(current, s0, r0, x0, y0)\n const vx = originX + x0 - p0.x\n const vy = originY + y0 - p0.y\n\n /**\n * Scale, rotation and x/y at progress `p` of the snap, keeping the\n * focal point in place.\n */\n const at = (p: number) => {\n const k = mixNumber(s0, s1, p)\n const r = mixNumber(r0, r1, p)\n const angle = ((r - r0) * Math.PI) / 180\n const cos = (Math.cos(angle) * k) / s0\n const sin = (Math.sin(angle) * k) / s0\n return [\n k,\n r,\n x0 + cos * vx - sin * vy - vx,\n y0 + sin * vx + cos * vy - vy,\n ]\n }\n\n if (\n !s0 ||\n (s1 === s0 && r1 === r0 && !(snapToOrigin && moves && (x0 || y0)))\n ) {\n return\n }\n\n const generator = spring({\n keyframes: [0, 1],\n stiffness: 200,\n damping: 40,\n ...transition,\n })\n const startTime = time.now()\n\n /**\n * Drive the values from one spring, from 0 to 1, so they stay in\n * step and the focal point stays in place.\n */\n const tick = () => {\n if (dragControls()?.isDragging) return stopSnap()\n\n const { value: p, done } = generator.next(time.now() - startTime)\n if (done) stopSnap()\n\n const [k, r, fx, fy] = at(p)\n\n scaleOption !== false && scale.set(k)\n rotateOption !== false && rotate.set(r)\n\n if (moves) {\n x.set(snapToOrigin ? mixNumber(x0, 0, p) : fx)\n y.set(snapToOrigin ? mixNumber(y0, 0, p) : fy)\n }\n }\n\n stopSnap = () => cancelFrame(tick)\n frame.update(tick, true)\n }\n\n /**\n * Apply the change in the gesture since the last frame as an\n * incremental scale and rotation around the previous focal point,\n * plus the focal point's movement.\n */\n const apply = () => {\n if (!values || !hasMoved) return\n hasMoved = false\n\n const {\n rotate: rotateOption,\n scale: scaleOption,\n pan,\n elastic,\n } = getOptions()\n const [scale, rotate, x, y] = values\n const resistance = resolveElastic(elastic)\n const latest = scale.get()\n const drag = dragControls()\n const isDragging = drag?.isDragging\n\n if (!isDragging) {\n lastX = x.get()\n lastY = y.get()\n }\n\n const p = pivot(prev, latest, rotate.get(), lastX, lastY)\n let theta = 0\n let k = 1\n\n /**\n * Apply limits and elastic to the gesture's raw scale and rotation.\n * At a hard limit, the raw value stops too, so moving back responds\n * straight away.\n */\n const constrain = (raw: number, option?: boolean | PinchLimits) => {\n const limits = limitsOf(option)\n const limit = clampTo(raw, limits)\n\n return resistance[raw < limit ? \"min\" : \"max\"]\n ? [applyConstraints(raw, limits, resistance), raw]\n : [limit, limit]\n }\n\n if (scaleOption !== false && latest) {\n const [next, raw] = constrain(\n clamp(1e-9, 1e9, rawScale * Math.exp(current.l - prev.l)),\n scaleOption\n )\n rawScale = raw\n k = next / latest\n scale.set(next)\n }\n\n if (rotateOption !== false) {\n const [next, raw] = constrain(\n rawRotate + current.a - prev.a,\n rotateOption\n )\n rawRotate = raw\n theta = next - rotate.get()\n if (theta) rotate.set(next)\n }\n\n if (writesXY(options)) {\n /**\n * Pinch owns x/y while it runs, so stop any animation started\n * on them since (like a drag's snap back) taking over after.\n */\n x.stop()\n y.stop()\n\n /**\n * If drag() or the drag prop is dragging this element with one\n * of the touches, it has set x/y this frame to where it started\n * plus the touch's offset. Carry on from our own values instead,\n * and restart the drag from them and the touch's latest point.\n * That way it continues from wherever the pinch leaves the\n * element, and its release velocity only counts movement after\n * the pinch, so a zoom doesn't end in a fling.\n */\n const angle = (theta * Math.PI) / 180\n const cos = Math.cos(angle) * k\n const sin = Math.sin(angle) * k\n const dx = p.x - originX - lastX\n const dy = p.y - originY - lastY\n const panX = pan !== false ? current.x - prev.x : 0\n const panY = pan !== false ? current.y - prev.y : 0\n\n /**\n * Move the centre so the pivot, scaled and rotated around the\n * centre, stays in place, plus the focal point's movement.\n */\n lastX += dx + panX - (cos * dx - sin * dy)\n lastY += dy + panY - (sin * dx + cos * dy)\n\n if (isDragging) {\n const history = drag!.panSession!.history\n history.splice(0, history.length - 1)\n\n /**\n * Date the point long ago, so drag only measures release\n * velocity from moves after the pinch. A move that drag\n * processes as the touch lifts is part of the pinch.\n */\n history[0].timestamp = -Infinity\n drag!.originPoint.x = lastX\n drag!.originPoint.y = lastY\n }\n\n x.set(lastX)\n y.set(lastY)\n }\n\n Object.assign(prev, current)\n handlers.onPinch?.(lastEvent, info())\n }\n\n /**\n * Runs after the update step, where drag sets x/y, so it has the final\n * say on them each frame.\n */\n const update = () => {\n if (!getEnabledOptions()) return end(lastEvent)\n\n apply()\n\n if (source === \"wheel\" && time.now() - wheelTime > wheelTimeout) {\n end(lastEvent)\n }\n }\n\n const begin = (event: Event, from: typeof source) => {\n if (!getEnabledOptions()) return\n\n stopSnap()\n source = from\n lastEvent = event\n hasMoved = false\n values = undefined\n handlers = {}\n Object.assign(start, current)\n Object.assign(prev, current)\n frame.read(measure)\n frame.preRender(update, true)\n\n const result = onPinchStart(element, event, info())\n handlers =\n typeof result === \"function\" ? { onComplete: result } : result || {}\n }\n\n const end = (event: Event) => {\n if (!source) return\n cancelFrame(measure)\n cancelFrame(update)\n\n if (getEnabledOptions()) {\n apply()\n values && snap()\n }\n\n source = undefined\n handlers.onComplete?.(event, info())\n }\n\n const moved = (event: Event) => {\n lastEvent = event\n hasMoved = true\n }\n\n const readPointers = () => {\n const [a, b] = pointers.values()\n const angle = (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI\n const delta = angle - current.a\n\n current.x = (a.x + b.x) / 2\n current.y = (a.y + b.y) / 2\n current.l = Math.log(Math.hypot(b.x - a.x, b.y - a.y) || 1)\n\n /**\n * Take the shortest way round, so rotation keeps counting past\n * 180deg rather than flipping to -180deg.\n */\n current.a += delta - 360 * Math.round(delta / 360)\n }\n\n const setPointer = (event: PointerEvent) =>\n pointers.set(event.pointerId, { x: event.clientX, y: event.clientY })\n\n const onPointerMove = (event: PointerEvent) => {\n if (!pointers.has(event.pointerId)) return\n setPointer(event)\n\n if (source === \"pointer\") {\n readPointers()\n moved(event)\n }\n }\n\n const onPointerUp = (event: PointerEvent) => {\n if (!pointers.delete(event.pointerId)) return\n\n if (source === \"pointer\") end(event)\n\n if (!pointers.size) {\n toggleWindowListeners()\n release()\n }\n }\n\n /**\n * Once a touch is down on the element, listen on the window too, so\n * the second touch can land beside it (for instance on a small image).\n */\n const onPointerDown = (event: PointerEvent) => {\n if (\n source ||\n pointers.size > 1 ||\n pointers.has(event.pointerId) ||\n event.pointerType === \"mouse\"\n ) {\n return\n }\n\n if (!pointers.size) toggleWindowListeners(true)\n setPointer(event)\n\n if (pointers.size === 2) {\n readPointers()\n begin(event, \"pointer\")\n\n /**\n * Unless this element drags, hold the drag lock until every\n * touch lifts. A press on it then ends as a cancel, rather than\n * a tap, and a draggable parent doesn't drag.\n */\n if (\n source &&\n !unlock &&\n !elementDragControls.get(visualElementStore.get(element)!)\n ) {\n unlock = setDragLock(true)\n }\n }\n }\n\n /**\n * Release the drag lock a frame later, so a press ending on this same\n * pointerup still sees it.\n */\n const release = () => {\n const done = unlock\n unlock = undefined\n done && frame.postRender(done)\n }\n\n const toggleWindowListeners = (add?: boolean) => {\n const method = add ? \"addEventListener\" : \"removeEventListener\"\n window[method](\"pointerdown\", onPointerDown as EventListener)\n window[method](\"pointermove\", onPointerMove as EventListener)\n window[method](\"pointerup\", onPointerUp as EventListener)\n window[method](\"pointercancel\", onPointerUp as EventListener)\n }\n\n const onWheel = (event: WheelEvent) => {\n if (!event.ctrlKey || (source && source !== \"wheel\")) return\n\n current.x = event.clientX\n current.y = event.clientY\n\n if (!source) {\n current.l = 0\n begin(event, \"wheel\")\n if (!source) return\n }\n\n event.preventDefault()\n\n /**\n * Lines (Firefox's mouse wheel) to pixels, and cap each event so a\n * mouse wheel notch with ctrl held (about 100px) zooms a step.\n */\n current.l -=\n clamp(-50, 50, event.deltaY * (event.deltaMode ? 16 : 1)) / 100\n wheelTime = time.now()\n moved(event)\n }\n\n /**\n * Safari reports trackpad pinches as `gesture*` events. iOS Safari\n * fires them for touches too, alongside the pointer events we track.\n */\n const onGesture = (event: Event) => {\n if (!pointers.size && (!source || source === \"gesture\")) {\n const { scale, rotation, clientX, clientY } = event as any\n current.x = clientX\n current.y = clientY\n current.l = Math.log(scale)\n current.a = rotation\n\n if (source) {\n moved(event)\n if (event.type === \"gestureend\") end(event)\n } else if (event.type === \"gesturestart\") {\n begin(event, \"gesture\")\n }\n }\n\n if (source) event.preventDefault()\n }\n\n const listeners = {\n pointerdown: onPointerDown,\n wheel: onWheel,\n gesturestart: onGesture,\n gesturechange: onGesture,\n gestureend: onGesture,\n }\n\n for (const name in listeners) {\n element.addEventListener(\n name,\n listeners[name as keyof typeof listeners] as EventListener,\n { passive: false }\n )\n }\n\n return () => {\n for (const name in listeners) {\n element.removeEventListener(\n name,\n listeners[name as keyof typeof listeners] as EventListener\n )\n }\n toggleWindowListeners()\n end(lastEvent)\n stopSnap()\n pointers.clear()\n release()\n }\n}\n\nconst valueKeys = [\"scale\", \"rotate\", \"x\", \"y\"]\n\n/**\n * The element's scale/rotate/x/y motion values: those of its\n * VisualElement if it has one (it's a <motion.*> component, or drag() or\n * animateLayout() own it), otherwise those animate() binds to it, created\n * from its current style if this is the first time.\n */\nconst getElementValues = (element: HTMLElement | SVGElement) => {\n const visualElement = visualElementStore.get(element)\n const effect = isSVGElement(element) ? svgSubjectEffect : styleSubjectEffect\n\n return valueKeys.map((key) => {\n if (visualElement) {\n return visualElement.getValue(key, key === \"scale\" ? 1 : 0)\n }\n\n let value = effect.get(element as any, key)\n\n if (!value) {\n value = motionValue(readStyleValue(element, key))\n effect(element as any, { [key]: value })\n }\n\n return value\n }) as PinchValues\n}\n\n/**\n * Make elements pinchable. Returns a function that removes the gesture.\n * The start callback is optional:\n *\n * ```javascript\n * pinch(\"img\")\n * pinch(\"img\", { scale: { min: 1, max: 4 } })\n * ```\n *\n * ```javascript\n * const stop = pinch(\"#photo\", (element, startEvent) => {\n * return (endEvent, info) => {}\n * }, { scale: { min: 1, max: 4 } })\n * ```\n *\n * `onPinchStart` is called once as each pinch starts. It can return a\n * function to call when the pinch ends, or an object of handlers:\n *\n * ```javascript\n * pinch(\"#photo\", () => ({\n * onPinch: (event, { scale }) => {},\n * onComplete: (event, info) => {},\n * }))\n * ```\n *\n * Touches, trackpad pinches and Safari's gesture events scale the element\n * around the focal point and move it with the touches. Its `scale`,\n * `rotate`, `x` and `y` are motion values shared with `animate()`, so an\n * `onComplete` handler can animate the element after a pinch.\n *\n * @public\n */\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n options?: PinchOptions\n): VoidFunction\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n onPinchStart?: OnPinchStartEvent,\n options?: PinchOptions\n): VoidFunction\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n startOrOptions?: OnPinchStartEvent | PinchOptions,\n options: PinchOptions = {}\n): VoidFunction {\n let onPinchStart: OnPinchStartEvent = () => {}\n\n if (typeof startOrOptions === \"function\") {\n onPinchStart = startOrOptions\n } else if (startOrOptions) {\n options = startOrOptions\n }\n\n const scope = activeScope.current\n\n /**\n * Run the start callback and the handlers it returns in the active\n * scope, so work they start is collected. A returned function is\n * bound by `scope.bind` itself.\n */\n if (scope) {\n const start = scope.bind(onPinchStart)\n onPinchStart = (element, event) => {\n const result = start(element, event)\n if (typeof result !== \"object\") return result\n\n const handlers: PinchHandlers = {}\n for (const key in result) {\n const name = key as keyof PinchHandlers\n const handler = result[name]\n handlers[name] = handler && scope.bind(handler)\n }\n return handlers\n }\n }\n\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element)\n\n const { style } = element as HTMLElement\n const touchAction = style.touchAction\n style.touchAction = \"none\"\n\n const remove = addPinchListeners(\n element,\n () => getElementValues(element as HTMLElement),\n () => options,\n onPinchStart\n )\n\n return () => {\n remove()\n style.touchAction = touchAction\n }\n })\n\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()))\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4MA;;;AAGG;AACH,MAAM,YAAY,GAAG,GAAG;AAExB;;;AAGG;AACH,MAAM,QAAQ,GAAG,CAAC,KAA0B,EAAE,IAAY,KAAI;AAC1D,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,EAAqB;AAE7C,IAAA,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC5B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IA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BACtB,MAAM,IAAI,GAAG,GAA0B;AACvC,gBAAA,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;AAC5B,gBAAA,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;YACnD;AACA,YAAA,OAAO,QAAQ;AACnB,QAAA,CAAC;IACL;AAEA,IAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,KAAI;AAChE,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;AAErB,QAAA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAsB;AACxC,QAAA,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW;AACrC,QAAA,KAAK,CAAC,WAAW,GAAG,MAAM;QAE1B,MAAM,MAAM,GAAG,iBAAiB,CAC5B,OAAO,EACP,MAAM,gBAAgB,CAAC,OAAsB,CAAC,EAC9C,MAAM,OAAO,EACb,YAAY,CACf;AAED,QAAA,OAAO,MAAK;AACR,YAAA,MAAM,EAAE;AACR,YAAA,KAAK,CAAC,WAAW,GAAG,WAAW;AACnC,QAAA,CAAC;AACL,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;AACrE;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/pinch/index.ts"],"sourcesContent":["import { clamp, type Point } from \"motion-utils\"\nimport { spring } from \"../../animation/generators/spring\"\nimport type { SpringOptions } from \"../../animation/types\"\nimport { readStyleValue, styleSubjectEffect } from \"../../effects/style\"\nimport { svgSubjectEffect } from \"../../effects/svg\"\nimport { cancelFrame, frame } from \"../../frameloop\"\nimport { time } from \"../../frameloop/sync-time\"\nimport { visualElementStore } from \"../../render/store\"\nimport { activeScope, addToScope } from \"../../scope/active\"\nimport { isSVGElement } from \"../../utils/is-svg-element\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../../utils/resolve-elements\"\nimport { motionValue, type MotionValue } from \"../../value\"\nimport { setDragLock } from \"../drag/state/set-active\"\nimport { applyConstraints, defaultElastic } from \"../drag/utils/constraints\"\nimport { elementDragControls } from \"../drag/VisualElementDragControls\"\n\n/**\n * @public\n */\nexport interface PinchInfo {\n /**\n * The gesture's focal point in client coordinates: the midpoint\n * between two touches, or the cursor for a trackpad pinch.\n */\n point: Point\n\n /**\n * How far the focal point has moved since the gesture started.\n */\n offset: Point\n\n /**\n * The gesture's scale relative to its start.\n */\n scale: number\n\n /**\n * The gesture's rotation since its start, in degrees.\n */\n rotate: number\n}\n\n/**\n * Called with the latest event and the gesture's info.\n *\n * @public\n */\nexport type OnPinchEvent = (event: Event, info: PinchInfo) => void\n\n/**\n * Handlers for a single pinch gesture, returned from the pinch start\n * callback.\n *\n * @public\n */\nexport interface PinchHandlers {\n /**\n * Called each frame the gesture changes, after the element's values\n * are updated.\n */\n onPinch?: OnPinchEvent\n\n /**\n * Called once when the gesture ends: a touch lifts or is cancelled, a\n * trackpad pinch stops, or the gesture is disabled or removed.\n *\n * Returning this function directly from the pinch start callback is\n * equivalent.\n */\n onComplete?: OnPinchEvent\n}\n\n/**\n * Called once when a pinch gesture starts: when a second touch lands, on\n * the first trackpad pinch event, or on Safari's `gesturestart`. Can\n * return a function to call when the pinch ends, or an object of\n * `PinchHandlers`.\n *\n * @public\n */\nexport type OnPinchStartEvent = (\n element: Element,\n event: Event\n) => OnPinchEvent | PinchHandlers | void\n\n/**\n * The limits of a pinch's scale or rotation.\n *\n * @public\n */\nexport interface PinchLimits {\n /**\n * The minimum. Past it, the gesture resists by `elastic`, and the\n * value springs back to it on release.\n */\n min?: number\n\n /**\n * The maximum. Past it, the gesture resists by `elastic`, and the\n * value springs back to it on release.\n */\n max?: number\n}\n\n/**\n * @public\n */\nexport interface PinchRotateOptions extends PinchLimits {\n /**\n * On release, rotate to the nearest multiple of this many degrees.\n */\n snap?: number\n}\n\n/**\n * @public\n */\nexport interface PinchOptions {\n /**\n * Scale the element. Defaults to `true`. Pass `{ min, max }` to limit\n * the scale.\n */\n scale?: boolean | PinchLimits\n\n /**\n * Rotate the element with the touches. Defaults to `true`. Pass\n * `{ min, max }` (in degrees) to limit the rotation, and `snap` to\n * rotate to the nearest multiple of `snap` degrees on release.\n */\n rotate?: boolean | PinchRotateOptions\n\n /**\n * Move the element with the focal point, and keep the point under the\n * fingers (or cursor) in place while scaling and rotating. Defaults to\n * `true`. Composes with drag: a drag that one of the touches started\n * carries on from wherever the pinch leaves the element (its offset\n * restarts there). Drag constraints aren't applied while pinching.\n *\n * Assumes the default `transform-origin` (the element's centre).\n */\n pan?: boolean\n\n /**\n * The point that scale and rotation pivot around. `\"pointer\"` (the\n * default) is the focal point between the touches, or the cursor.\n * `{ x, y }` is a point on the element, as a fraction of its width\n * and height: `{ x: 0.5, y: 0.5 }` is its centre. With `pan: false`,\n * the default is the centre.\n */\n origin?: \"pointer\" | Point\n\n /**\n * How far scale and rotation can go past their limits, as for\n * `dragElastic`: `0` stops at the limit, `1` doesn't resist. Pass\n * `{ min, max }` to set each side. Defaults to `0.35`.\n */\n elastic?: boolean | number | PinchLimits\n\n /**\n * On release, animate scale back to `1`, and rotation and `x`/`y`\n * back to `0`.\n */\n snapToOrigin?: boolean\n\n /**\n * The spring values use to animate back inside their limits, to a\n * `snap` angle or to their origin.\n */\n transition?: SpringOptions\n}\n\n/**\n * Options for the `pinch` prop.\n *\n * @public\n */\nexport interface PinchProps extends PinchOptions {\n /**\n * Called when the pinch starts.\n */\n onStart?: OnPinchEvent\n\n /**\n * Called each frame the pinch changes.\n */\n onMove?: OnPinchEvent\n\n /**\n * Called when the pinch ends.\n */\n onEnd?: OnPinchEvent\n}\n\nexport type PinchValues = [\n scale: MotionValue<number>,\n rotate: MotionValue<number>,\n x: MotionValue<number>,\n y: MotionValue<number>,\n]\n\n/**\n * A trackpad pinch arrives as a stream of `wheel` events with no end\n * event, so it ends once none have arrived for this long.\n */\nconst wheelTimeout = 150\n\n/**\n * Convert an `x`/`y` set in other units (e.g. `\"-50%\"` to centre an\n * element) to pixels, so the gesture can add to it.\n */\nconst toPixels = (value: MotionValue<number>, size: number) => {\n const latest = value.get() as number | string\n\n if (typeof latest === \"string\") {\n value.set(parseFloat(latest) * (latest.endsWith(\"%\") ? size / 100 : 1))\n }\n}\n\nconst limitsOf = (option?: boolean | PinchRotateOptions): PinchRotateOptions =>\n typeof option === \"object\" ? option : {}\n\n/**\n * Resolve `elastic` to a resistance for each side, as for `dragElastic`.\n */\nconst resolveElastic = (\n elastic: PinchOptions[\"elastic\"] = defaultElastic\n): { min: number; max: number } => {\n const side = (value?: number | boolean) =>\n value === true ? defaultElastic : +(value || 0)\n\n return typeof elastic === \"object\"\n ? { min: side(elastic.min), max: side(elastic.max) }\n : { min: side(elastic), max: side(elastic) }\n}\n\n/**\n * Whether the gesture writes `x`/`y`: to follow the focal point, or to\n * keep an `origin` on the element in place.\n */\nconst writesXY = ({ pan, origin }: PinchOptions) => pan !== false || !!origin\n\nconst clampTo = (value: number, { min = -Infinity, max = Infinity }) =>\n clamp(min, max, value)\n\n/**\n * The raw gesture value that elastic shows as `value`. A pinch that starts\n * while a value is still past its limit (like during a spring back) carries\n * on from it, rather than jumping.\n */\nconst unconstrain = (\n value: number,\n option: boolean | PinchRotateOptions | undefined,\n resistance: { min: number; max: number }\n) => {\n const limit = clampTo(value, limitsOf(option))\n const elastic = resistance[value < limit ? \"min\" : \"max\"]\n\n return elastic ? limit + (value - limit) / elastic : value\n}\n\n/**\n * Listen for pinch gestures on `element`: two touches (or pens), a trackpad\n * pinch (`wheel` with `ctrlKey`, as Chrome, Edge and Firefox report it),\n * and Safari's `gesture*` events.\n *\n * `getValues` is called each time a gesture starts, in the frame's read\n * step, for the scale/rotate/x/y values to write to. It runs alongside the\n * element measurement so neither forces a layout.\n *\n * `getOptions` is read whenever it's needed, so options can change while\n * listening. Return `false` to disable the gesture, which also ends one in\n * progress.\n *\n * `onPinchStart` is called once as each gesture starts, with the gesture's\n * info as a third argument. It can return the gesture's handlers, as for\n * `pinch()`.\n */\nexport function addPinchListeners(\n element: Element,\n getValues: () => PinchValues,\n getEnabledOptions: () => PinchOptions | false | undefined,\n onPinchStart: (\n element: Element,\n event: Event,\n info: PinchInfo\n ) => ReturnType<OnPinchStartEvent>\n): VoidFunction {\n const pointers = new Map<number, Point>()\n\n /**\n * The gesture as last reported: focal point, log of a distance and an\n * angle. Only changes in distance and angle matter, so trackpad and\n * Safari input write a virtual distance (the scale) here. Logs keep\n * a long trackpad pinch from overflowing.\n */\n const current = { x: 0, y: 0, l: 0, a: 0 }\n const start = { ...current }\n const prev = { ...current }\n\n let source: \"pointer\" | \"wheel\" | \"gesture\" | undefined\n let lastEvent: Event\n let values: PinchValues | undefined\n let originX = 0\n let originY = 0\n let width = 0\n let height = 0\n let lastX = 0\n let lastY = 0\n let hasMoved = false\n let wheelTime = 0\n let handlers: PinchHandlers = {}\n let unlock: VoidFunction | null | undefined\n\n /**\n * The gesture's scale and rotation before limits and elastic apply.\n */\n let rawScale = 1\n let rawRotate = 0\n let stopSnap = () => {}\n\n /**\n * The latest enabled options, so a gesture disabled mid-way can still\n * report its end.\n */\n let options: PinchOptions = {}\n const getOptions = () => (options = getEnabledOptions() || options)\n\n const info = (): PinchInfo => ({\n point: { x: current.x, y: current.y },\n offset: { x: current.x - start.x, y: current.y - start.y },\n scale: Math.exp(current.l - start.l),\n rotate: current.a - start.a,\n })\n\n /**\n * Read the element's box and values, and find its layout origin: its\n * centre without `x`/`y`. Scale and rotate are applied around the\n * centre (the default transform origin), so they don't move it.\n */\n const measure = () => {\n const box = element.getBoundingClientRect()\n const { left, top } = box\n const { scale, rotate, elastic } = getOptions()\n const [s, r, x, y] = (values = getValues())\n const resistance = resolveElastic(elastic)\n\n /**\n * Stop animations on values this gesture writes, and leave the\n * rest running.\n */\n scale !== false && s.stop()\n rotate !== false && r.stop()\n rawScale = unconstrain(s.get(), scale, resistance)\n rawRotate = unconstrain(r.get(), rotate, resistance)\n\n width = (element as HTMLElement).offsetWidth ?? box.width\n height = (element as HTMLElement).offsetHeight ?? box.height\n\n if (writesXY(options)) {\n x.stop()\n y.stop()\n toPixels(x, width)\n toPixels(y, height)\n }\n\n lastX = x.get()\n lastY = y.get()\n originX = left + box.width / 2 - lastX\n originY = top + box.height / 2 - lastY\n }\n\n /**\n * The point scale and rotation pivot around, in client coordinates:\n * the focal point, or `origin` on the element at scale `s`, rotation\n * `r` and offset `x`/`y`.\n */\n const pivot = (\n focal: Point,\n s: number,\n r: number,\n x: number,\n y: number\n ): Point => {\n const { origin } = options\n if (typeof origin !== \"object\") return focal\n\n const a = (r * Math.PI) / 180\n const u = (origin.x - 0.5) * width * s\n const v = (origin.y - 0.5) * height * s\n\n return {\n x: originX + x + Math.cos(a) * u - Math.sin(a) * v,\n y: originY + y + Math.sin(a) * u + Math.cos(a) * v,\n }\n }\n\n const dragControls = () =>\n elementDragControls.get(visualElementStore.get(element)!)\n\n /**\n * On release, spring scale and rotation back inside their limits (or\n * to a `snap` angle), keeping the focal point in place, or everything\n * back to its origin with `snapToOrigin`.\n */\n const snap = () => {\n const {\n scale: scaleOption,\n rotate: rotateOption,\n snapToOrigin,\n transition,\n } = options\n const [scale, rotate, x, y] = values!\n const s0 = scale.get()\n const r0 = rotate.get()\n const x0 = x.get()\n const y0 = y.get()\n const { snap: step } = limitsOf(rotateOption)\n let s1 = clampTo(s0, limitsOf(scaleOption))\n /**\n * Snap to the step nearest where the release velocity would carry\n * the rotation, found as inertia finds its target (with a lower power\n * than inertia's 0.8).\n */\n let r1 = clampTo(\n step\n ? Math.round((r0 + 0.2 * rotate.getVelocity()) / step) * step\n : r0,\n limitsOf(rotateOption)\n )\n\n if (snapToOrigin) {\n s1 = 1\n // The nearest upright angle, so it turns the shortest way\n r1 = Math.round(r0 / 360) * 360\n }\n\n /**\n * Keep the focal point in place, unless the element doesn't move\n * with it, or a drag carries on and owns x/y.\n */\n const moves = writesXY(options) && !dragControls()?.isDragging\n const p0 = pivot(current, s0, r0, x0, y0)\n const vx = originX + x0 - p0.x\n const vy = originY + y0 - p0.y\n\n /**\n * Scale, rotation and x/y at progress `p` of the snap, keeping the\n * focal point in place.\n */\n const at = (p: number) => {\n const k = mixNumber(s0, s1, p)\n const r = mixNumber(r0, r1, p)\n const angle = ((r - r0) * Math.PI) / 180\n const cos = (Math.cos(angle) * k) / s0\n const sin = (Math.sin(angle) * k) / s0\n return [\n k,\n r,\n x0 + cos * vx - sin * vy - vx,\n y0 + sin * vx + cos * vy - vy,\n ]\n }\n\n if (\n !s0 ||\n (s1 === s0 && r1 === r0 && !(snapToOrigin && moves && (x0 || y0)))\n ) {\n return\n }\n\n const generator = spring({\n keyframes: [0, 1],\n stiffness: 200,\n damping: 40,\n ...transition,\n })\n const startTime = time.now()\n\n /**\n * Drive the values from one spring, from 0 to 1, so they stay in\n * step and the focal point stays in place.\n */\n const tick = () => {\n const { value: p, done } = generator.next(time.now() - startTime)\n if (done) stopSnap()\n\n const [k, r, fx, fy] = at(p)\n\n scaleOption !== false && scale.set(k)\n rotateOption !== false && rotate.set(r)\n\n // A drag that starts mid-snap owns x/y from then on.\n if (moves && !dragControls()?.isDragging) {\n x.set(snapToOrigin ? mixNumber(x0, 0, p) : fx)\n y.set(snapToOrigin ? mixNumber(y0, 0, p) : fy)\n }\n }\n\n stopSnap = () => cancelFrame(tick)\n frame.update(tick, true)\n }\n\n /**\n * Apply the change in the gesture since the last frame as an\n * incremental scale and rotation around the previous focal point,\n * plus the focal point's movement.\n */\n const apply = () => {\n if (!values || !hasMoved) return\n hasMoved = false\n\n const {\n rotate: rotateOption,\n scale: scaleOption,\n pan,\n elastic,\n } = getOptions()\n const [scale, rotate, x, y] = values\n const resistance = resolveElastic(elastic)\n const latest = scale.get()\n const drag = dragControls()\n const isDragging = drag?.isDragging\n\n if (!isDragging) {\n lastX = x.get()\n lastY = y.get()\n }\n\n const p = pivot(prev, latest, rotate.get(), lastX, lastY)\n let theta = 0\n let k = 1\n\n /**\n * Apply limits and elastic to the gesture's raw scale and rotation.\n * At a hard limit, the raw value stops too, so moving back responds\n * straight away.\n */\n const constrain = (raw: number, option?: boolean | PinchLimits) => {\n const limits = limitsOf(option)\n const limit = clampTo(raw, limits)\n\n return resistance[raw < limit ? \"min\" : \"max\"]\n ? [applyConstraints(raw, limits, resistance), raw]\n : [limit, limit]\n }\n\n if (scaleOption !== false && latest) {\n const [next, raw] = constrain(\n clamp(1e-9, 1e9, rawScale * Math.exp(current.l - prev.l)),\n scaleOption\n )\n rawScale = raw\n k = next / latest\n scale.set(next)\n }\n\n if (rotateOption !== false) {\n const [next, raw] = constrain(\n rawRotate + current.a - prev.a,\n rotateOption\n )\n rawRotate = raw\n theta = next - rotate.get()\n if (theta) rotate.set(next)\n }\n\n if (writesXY(options)) {\n /**\n * Pinch owns x/y while it runs, so stop any animation started\n * on them since (like a drag's snap back) taking over after.\n */\n x.stop()\n y.stop()\n\n /**\n * If drag() or the drag prop is dragging this element with one\n * of the touches, it has set x/y this frame to where it started\n * plus the touch's offset. Carry on from our own values instead,\n * and restart the drag from them and the touch's latest point.\n * That way it continues from wherever the pinch leaves the\n * element, and its release velocity only counts movement after\n * the pinch, so a zoom doesn't end in a fling.\n */\n const angle = (theta * Math.PI) / 180\n const cos = Math.cos(angle) * k\n const sin = Math.sin(angle) * k\n const dx = p.x - originX - lastX\n const dy = p.y - originY - lastY\n const panX = pan !== false ? current.x - prev.x : 0\n const panY = pan !== false ? current.y - prev.y : 0\n\n /**\n * Move the centre so the pivot, scaled and rotated around the\n * centre, stays in place, plus the focal point's movement.\n */\n lastX += dx + panX - (cos * dx - sin * dy)\n lastY += dy + panY - (sin * dx + cos * dy)\n\n if (isDragging) {\n const history = drag!.panSession!.history\n history.splice(0, history.length - 1)\n\n /**\n * Date the point long ago, so drag only measures release\n * velocity from moves after the pinch. A move that drag\n * processes as the touch lifts is part of the pinch.\n */\n history[0].timestamp = -Infinity\n drag!.originPoint.x = lastX\n drag!.originPoint.y = lastY\n }\n\n x.set(lastX)\n y.set(lastY)\n }\n\n Object.assign(prev, current)\n handlers.onPinch?.(lastEvent, info())\n }\n\n /**\n * Runs after the update step, where drag sets x/y, so it has the final\n * say on them each frame.\n */\n const update = () => {\n if (!getEnabledOptions()) return end(lastEvent)\n\n apply()\n\n if (source === \"wheel\" && time.now() - wheelTime > wheelTimeout) {\n end(lastEvent)\n }\n }\n\n const begin = (event: Event, from: typeof source) => {\n if (!getEnabledOptions()) return\n\n stopSnap()\n source = from\n lastEvent = event\n hasMoved = false\n values = undefined\n handlers = {}\n Object.assign(start, current)\n Object.assign(prev, current)\n frame.read(measure)\n frame.preRender(update, true)\n\n const result = onPinchStart(element, event, info())\n handlers =\n typeof result === \"function\" ? { onComplete: result } : result || {}\n }\n\n const end = (event: Event) => {\n if (!source) return\n cancelFrame(measure)\n cancelFrame(update)\n\n if (getEnabledOptions()) {\n apply()\n values && snap()\n }\n\n source = undefined\n handlers.onComplete?.(event, info())\n }\n\n const moved = (event: Event) => {\n lastEvent = event\n hasMoved = true\n }\n\n const readPointers = () => {\n const [a, b] = pointers.values()\n const angle = (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI\n const delta = angle - current.a\n\n current.x = (a.x + b.x) / 2\n current.y = (a.y + b.y) / 2\n current.l = Math.log(Math.hypot(b.x - a.x, b.y - a.y) || 1)\n\n /**\n * Take the shortest way round, so rotation keeps counting past\n * 180deg rather than flipping to -180deg.\n */\n current.a += delta - 360 * Math.round(delta / 360)\n }\n\n const setPointer = (event: PointerEvent) =>\n pointers.set(event.pointerId, { x: event.clientX, y: event.clientY })\n\n const onPointerMove = (event: PointerEvent) => {\n if (!pointers.has(event.pointerId)) return\n setPointer(event)\n\n if (source === \"pointer\") {\n readPointers()\n moved(event)\n }\n }\n\n const onPointerUp = (event: PointerEvent) => {\n if (!pointers.delete(event.pointerId)) return\n\n if (source === \"pointer\") end(event)\n\n if (!pointers.size) {\n toggleWindowListeners()\n release()\n }\n }\n\n /**\n * Once a touch is down on the element, listen on the window too, so\n * the second touch can land beside it (for instance on a small image).\n */\n const onPointerDown = (event: PointerEvent) => {\n if (\n source ||\n pointers.size > 1 ||\n pointers.has(event.pointerId) ||\n event.pointerType === \"mouse\"\n ) {\n return\n }\n\n if (!pointers.size) toggleWindowListeners(true)\n setPointer(event)\n\n if (pointers.size === 2) {\n readPointers()\n begin(event, \"pointer\")\n\n /**\n * Unless this element drags, hold the drag lock until every\n * touch lifts. A press on it then ends as a cancel, rather than\n * a tap, and a draggable parent doesn't drag.\n */\n if (\n source &&\n !unlock &&\n !elementDragControls.get(visualElementStore.get(element)!)\n ) {\n unlock = setDragLock(true)\n }\n }\n }\n\n /**\n * Release the drag lock a frame later, so a press ending on this same\n * pointerup still sees it.\n */\n const release = () => {\n const done = unlock\n unlock = undefined\n done && frame.postRender(done)\n }\n\n const toggleWindowListeners = (add?: boolean) => {\n const method = add ? \"addEventListener\" : \"removeEventListener\"\n window[method](\"pointerdown\", onPointerDown as EventListener)\n window[method](\"pointermove\", onPointerMove as EventListener)\n window[method](\"pointerup\", onPointerUp as EventListener)\n window[method](\"pointercancel\", onPointerUp as EventListener)\n }\n\n const onWheel = (event: WheelEvent) => {\n if (!event.ctrlKey || (source && source !== \"wheel\")) return\n\n current.x = event.clientX\n current.y = event.clientY\n\n if (!source) {\n current.l = 0\n begin(event, \"wheel\")\n if (!source) return\n }\n\n event.preventDefault()\n\n /**\n * Lines (Firefox's mouse wheel) to pixels, and cap each event so a\n * mouse wheel notch with ctrl held (about 100px) zooms a step.\n */\n current.l -=\n clamp(-50, 50, event.deltaY * (event.deltaMode ? 16 : 1)) / 100\n wheelTime = time.now()\n moved(event)\n }\n\n /**\n * Safari reports trackpad pinches as `gesture*` events. iOS Safari\n * fires them for touches too, alongside the pointer events we track.\n */\n const onGesture = (event: Event) => {\n if (!pointers.size && (!source || source === \"gesture\")) {\n const { scale, rotation, clientX, clientY } = event as any\n current.x = clientX\n current.y = clientY\n current.l = Math.log(scale)\n current.a = rotation\n\n if (source) {\n moved(event)\n if (event.type === \"gestureend\") end(event)\n } else if (event.type === \"gesturestart\") {\n begin(event, \"gesture\")\n }\n }\n\n if (source) event.preventDefault()\n }\n\n const listeners = {\n pointerdown: onPointerDown,\n wheel: onWheel,\n gesturestart: onGesture,\n gesturechange: onGesture,\n gestureend: onGesture,\n }\n\n for (const name in listeners) {\n element.addEventListener(\n name,\n listeners[name as keyof typeof listeners] as EventListener,\n { passive: false }\n )\n }\n\n return () => {\n for (const name in listeners) {\n element.removeEventListener(\n name,\n listeners[name as keyof typeof listeners] as EventListener\n )\n }\n toggleWindowListeners()\n end(lastEvent)\n stopSnap()\n pointers.clear()\n release()\n }\n}\n\nconst valueKeys = [\"scale\", \"rotate\", \"x\", \"y\"]\n\n/**\n * The element's scale/rotate/x/y motion values: those of its\n * VisualElement if it has one (it's a <motion.*> component, or drag() or\n * animateLayout() own it), otherwise those animate() binds to it, created\n * from its current style if this is the first time.\n */\nconst getElementValues = (element: HTMLElement | SVGElement) => {\n const visualElement = visualElementStore.get(element)\n const effect = isSVGElement(element) ? svgSubjectEffect : styleSubjectEffect\n\n return valueKeys.map((key) => {\n if (visualElement) {\n return visualElement.getValue(key, key === \"scale\" ? 1 : 0)\n }\n\n let value = effect.get(element as any, key)\n\n if (!value) {\n value = motionValue(readStyleValue(element, key))\n effect(element as any, { [key]: value })\n }\n\n return value\n }) as PinchValues\n}\n\n/**\n * Make elements pinchable. Returns a function that removes the gesture.\n * The start callback is optional:\n *\n * ```javascript\n * pinch(\"img\")\n * pinch(\"img\", { scale: { min: 1, max: 4 } })\n * ```\n *\n * ```javascript\n * const stop = pinch(\"#photo\", (element, startEvent) => {\n * return (endEvent, info) => {}\n * }, { scale: { min: 1, max: 4 } })\n * ```\n *\n * `onPinchStart` is called once as each pinch starts. It can return a\n * function to call when the pinch ends, or an object of handlers:\n *\n * ```javascript\n * pinch(\"#photo\", () => ({\n * onPinch: (event, { scale }) => {},\n * onComplete: (event, info) => {},\n * }))\n * ```\n *\n * Touches, trackpad pinches and Safari's gesture events scale the element\n * around the focal point and move it with the touches. Its `scale`,\n * `rotate`, `x` and `y` are motion values shared with `animate()`, so an\n * `onComplete` handler can animate the element after a pinch.\n *\n * @public\n */\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n options?: PinchOptions\n): VoidFunction\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n onPinchStart?: OnPinchStartEvent,\n options?: PinchOptions\n): VoidFunction\nexport function pinch(\n elementOrSelector: ElementOrSelector,\n startOrOptions?: OnPinchStartEvent | PinchOptions,\n options: PinchOptions = {}\n): VoidFunction {\n let onPinchStart: OnPinchStartEvent = () => {}\n\n if (typeof startOrOptions === \"function\") {\n onPinchStart = startOrOptions\n } else if (startOrOptions) {\n options = startOrOptions\n }\n\n const scope = activeScope.current\n\n /**\n * Run the start callback and the handlers it returns in the active\n * scope, so work they start is collected. A returned function is\n * bound by `scope.bind` itself.\n */\n if (scope) {\n const start = scope.bind(onPinchStart)\n onPinchStart = (element, event) => {\n const result = start(element, event)\n if (typeof result !== \"object\") return result\n\n const handlers: PinchHandlers = {}\n for (const key in result) {\n const name = key as keyof PinchHandlers\n const handler = result[name]\n handlers[name] = handler && scope.bind(handler)\n }\n return handlers\n }\n }\n\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element)\n\n const { style } = element as HTMLElement\n const touchAction = style.touchAction\n style.touchAction = \"none\"\n\n const remove = addPinchListeners(\n element,\n () => getElementValues(element as HTMLElement),\n () => options,\n onPinchStart\n )\n\n return () => {\n remove()\n style.touchAction = touchAction\n }\n })\n\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()))\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4MA;;;AAGG;AACH,MAAM,YAAY,GAAG,GAAG;AAExB;;;AAGG;AACH,MAAM,Q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,OAAO,EAAE,KAAK,KAAI;YAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;YACpC,IAAI,OAAO,MAAM,KAAK,QAAQ;AAAE,gBAAA,OAAO,MAAM;YAE7C,MAAM,QAAQ,GAAkB,EAAE;AAClC,YAAA,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;gBACtB,MAAM,IAAI,GAAG,GAA0B;AACvC,gBAAA,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;AAC5B,gBAAA,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;YACnD;AACA,YAAA,OAAO,QAAQ;AACnB,QAAA,CAAC;IACL;AAEA,IAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,KAAI;AAChE,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;AAErB,QAAA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAsB;AACxC,QAAA,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW;AACrC,QAAA,KAAK,CAAC,WAAW,GAAG,MAAM;QAE1B,MAAM,MAAM,GAAG,iBAAiB,CAC5B,OAAO,EACP,MAAM,gBAAgB,CAAC,OAAsB,CAAC,EAC9C,MAAM,OAAO,EACb,YAAY,CACf;AAED,QAAA,OAAO,MAAK;AACR,YAAA,MAAM,EAAE;AACR,YAAA,KAAK,CAAC,WAAW,GAAG,WAAW;AACnC,QAAA,CAAC;AACL,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;AACrE;;;;"}
|
package/dist/es/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ export { optimizedAppearDataAttribute, optimizedAppearDataId } from './animation
|
|
|
24
24
|
export { getOptimisedAppearId } from './animation/optimized-appear/get-appear-id.mjs';
|
|
25
25
|
export { inertia } from './animation/generators/inertia.mjs';
|
|
26
26
|
export { defaultEasing, keyframes } from './animation/generators/keyframes.mjs';
|
|
27
|
-
export { spring } from './animation/generators/spring.mjs';
|
|
27
|
+
export { getSpringOptions, spring } from './animation/generators/spring.mjs';
|
|
28
28
|
export { calcGeneratorDuration, maxGeneratorDuration } from './animation/generators/utils/calc-duration.mjs';
|
|
29
29
|
export { createGeneratorEasing } from './animation/generators/utils/create-generator-easing.mjs';
|
|
30
30
|
export { isGenerator } from './animation/generators/utils/is-generator.mjs';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { clamp, secondsToMilliseconds } from 'motion-utils';
|
|
2
|
+
import { getSpringOptions } from '../../animation/generators/spring.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A curved path ties x and y to one progress value, so it takes the part of
|
|
6
|
+
* the velocity along the straight line from start to end.
|
|
7
|
+
*/
|
|
8
|
+
const pointToProgressVelocity = (tx, ty, { x, y }) => {
|
|
9
|
+
const lengthSquared = tx * tx + ty * ty;
|
|
10
|
+
return lengthSquared < 1 ? 0 : (-1e3 * (x * tx + y * ty)) / lengthSquared;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* With `mass: "auto"`, mass comes from the element's size: a 300px square
|
|
14
|
+
* has mass 1, bigger elements are heavier and slower (mass 0.25 to 2), and
|
|
15
|
+
* damping scales with mass so the spring keeps its bounce. The result is a
|
|
16
|
+
* physics spring.
|
|
17
|
+
*/
|
|
18
|
+
const resolveAutoMass = (t, size = 300) => {
|
|
19
|
+
const mass = clamp(0.25, 2, size / 300);
|
|
20
|
+
const { stiffness, damping } = getSpringOptions({
|
|
21
|
+
...t,
|
|
22
|
+
duration: t.duration && secondsToMilliseconds(t.duration),
|
|
23
|
+
});
|
|
24
|
+
return { ...t, stiffness, damping: damping * Math.sqrt(mass), mass };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { pointToProgressVelocity, resolveAutoMass };
|
|
28
|
+
//# sourceMappingURL=layout-velocity.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-velocity.mjs","sources":["../../../../src/projection/animation/layout-velocity.ts"],"sourcesContent":["import { clamp, Point, secondsToMilliseconds } from \"motion-utils\"\nimport { getSpringOptions } from \"../../animation/generators/spring\"\nimport type { ValueAnimationOptions } from \"../../animation/types\"\n\n/**\n * A curved path ties x and y to one progress value, so it takes the part of\n * the velocity along the straight line from start to end.\n */\nexport const pointToProgressVelocity = (\n tx: number,\n ty: number,\n { x, y }: Point\n) => {\n const lengthSquared = tx * tx + ty * ty\n return lengthSquared < 1 ? 0 : (-1000 * (x * tx + y * ty)) / lengthSquared\n}\n\n/**\n * With `mass: \"auto\"`, mass comes from the element's size: a 300px square\n * has mass 1, bigger elements are heavier and slower (mass 0.25 to 2), and\n * damping scales with mass so the spring keeps its bounce. The result is a\n * physics spring.\n */\nexport const resolveAutoMass = (\n t: any,\n size = 300\n): ValueAnimationOptions<number> => {\n const mass = clamp(0.25, 2, size / 300)\n const { stiffness, damping } = getSpringOptions({\n ...t,\n duration: t.duration && secondsToMilliseconds(t.duration),\n })\n return { ...t, stiffness, damping: damping * Math.sqrt(mass), mass }\n}\n"],"names":[],"mappings":";;;AAIA;;;AAGG;AACI,MAAM,uBAAuB,GAAG,CACnC,EAAU,EACV,EAAU,EACV,EAAE,CAAC,EAAE,CAAC,EAAS,KACf;IACA,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;IACvC,OAAO,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,aAAa;AAC9E;AAEA;;;;;AAKG;AACI,MAAM,eAAe,GAAG,CAC3B,CAAM,EACN,IAAI,GAAG,GAAG,KACqB;AAC/B,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC;AACvC,IAAA,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;AAC5C,QAAA,GAAG,CAAC;QACJ,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,KAAA,CAAC;AACF,IAAA,OAAO,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;AACxE;;;;"}
|