motion-dom 12.6.0 → 12.6.3-alpha.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 CHANGED
@@ -597,18 +597,6 @@ function hover(elementOrSelector, onHoverStart, options = {}) {
597
597
  return cancel;
598
598
  }
599
599
 
600
- function capturePointer(event, action) {
601
- const actionName = `${action}PointerCapture`;
602
- if (event.target instanceof Element &&
603
- actionName in event.target &&
604
- event.pointerId !== undefined) {
605
- try {
606
- event.target[actionName](event.pointerId);
607
- }
608
- catch (e) { }
609
- }
610
- }
611
-
612
600
  /**
613
601
  * Recursively traverse up the tree to check whether the provided child node
614
602
  * is the parent or a descendant of it.
@@ -724,15 +712,13 @@ function press(targetOrSelector, onPressStart, options = {}) {
724
712
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
725
713
  const startPress = (startEvent) => {
726
714
  const target = startEvent.currentTarget;
727
- if (!target || !isValidPressEvent(startEvent) || isPressing.has(target))
715
+ if (!isValidPressEvent(startEvent) || isPressing.has(target))
728
716
  return;
729
717
  isPressing.add(target);
730
- capturePointer(startEvent, "set");
731
718
  const onPressEnd = onPressStart(target, startEvent);
732
719
  const onPointerEnd = (endEvent, success) => {
733
- target.removeEventListener("pointerup", onPointerUp);
734
- target.removeEventListener("pointercancel", onPointerCancel);
735
- capturePointer(endEvent, "release");
720
+ window.removeEventListener("pointerup", onPointerUp);
721
+ window.removeEventListener("pointercancel", onPointerCancel);
736
722
  if (!isValidPressEvent(endEvent) || !isPressing.has(target)) {
737
723
  return;
738
724
  }
@@ -742,54 +728,30 @@ function press(targetOrSelector, onPressStart, options = {}) {
742
728
  }
743
729
  };
744
730
  const onPointerUp = (upEvent) => {
745
- const isOutside = !upEvent.isTrusted
746
- ? false
747
- : checkOutside(upEvent, target instanceof Element
748
- ? target.getBoundingClientRect()
749
- : {
750
- left: 0,
751
- top: 0,
752
- right: window.innerWidth,
753
- bottom: window.innerHeight,
754
- });
755
- if (isOutside) {
756
- onPointerEnd(upEvent, false);
757
- }
758
- else {
759
- onPointerEnd(upEvent, !(target instanceof Element) ||
760
- isNodeOrChild(target, upEvent.target));
761
- }
731
+ onPointerEnd(upEvent, target === window ||
732
+ target === document ||
733
+ options.useGlobalTarget ||
734
+ isNodeOrChild(target, upEvent.target));
762
735
  };
763
736
  const onPointerCancel = (cancelEvent) => {
764
737
  onPointerEnd(cancelEvent, false);
765
738
  };
766
- target.addEventListener("pointerup", onPointerUp, eventOptions);
767
- target.addEventListener("pointercancel", onPointerCancel, eventOptions);
768
- target.addEventListener("lostpointercapture", onPointerCancel, eventOptions);
739
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
740
+ window.addEventListener("pointercancel", onPointerCancel, eventOptions);
769
741
  };
770
742
  targets.forEach((target) => {
771
- target = options.useGlobalTarget ? window : target;
772
- let canAddKeyboardAccessibility = false;
743
+ const pointerDownTarget = options.useGlobalTarget ? window : target;
744
+ pointerDownTarget.addEventListener("pointerdown", startPress, eventOptions);
773
745
  if (target instanceof HTMLElement) {
774
- canAddKeyboardAccessibility = true;
746
+ target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
775
747
  if (!isElementKeyboardAccessible(target) &&
776
- target.getAttribute("tabindex") === null) {
748
+ target.tabIndex === null) {
777
749
  target.tabIndex = 0;
778
750
  }
779
751
  }
780
- target.addEventListener("pointerdown", startPress, eventOptions);
781
- if (canAddKeyboardAccessibility) {
782
- target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
783
- }
784
752
  });
785
753
  return cancelEvents;
786
754
  }
787
- function checkOutside(event, rect) {
788
- return (event.clientX < rect.left ||
789
- event.clientX > rect.right ||
790
- event.clientY < rect.top ||
791
- event.clientY > rect.bottom);
792
- }
793
755
 
794
756
  const activeAnimations = {
795
757
  layout: 0,
@@ -933,7 +895,7 @@ class MotionValue {
933
895
  * This will be replaced by the build step with the latest version number.
934
896
  * When MotionValues are provided to motion components, warn if versions are mixed.
935
897
  */
936
- this.version = "12.6.0";
898
+ this.version = "12.6.3-alpha.0";
937
899
  /**
938
900
  * Tracks whether this value can output a velocity. Currently this is only true
939
901
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -1585,7 +1547,6 @@ exports.attachTimeline = attachTimeline;
1585
1547
  exports.calcGeneratorDuration = calcGeneratorDuration;
1586
1548
  exports.cancelFrame = cancelFrame;
1587
1549
  exports.cancelMicrotask = cancelMicrotask;
1588
- exports.capturePointer = capturePointer;
1589
1550
  exports.collectMotionValues = collectMotionValues;
1590
1551
  exports.createGeneratorEasing = createGeneratorEasing;
1591
1552
  exports.createRenderBatcher = createRenderBatcher;
@@ -1,5 +1,4 @@
1
1
  import { isDragActive } from '../drag/state/is-active.mjs';
2
- import { capturePointer } from '../utils/capture-pointer.mjs';
3
2
  import { isNodeOrChild } from '../utils/is-node-or-child.mjs';
4
3
  import { isPrimaryPointer } from '../utils/is-primary-pointer.mjs';
5
4
  import { setupGesture } from '../utils/setup.mjs';
@@ -37,15 +36,13 @@ function press(targetOrSelector, onPressStart, options = {}) {
37
36
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
38
37
  const startPress = (startEvent) => {
39
38
  const target = startEvent.currentTarget;
40
- if (!target || !isValidPressEvent(startEvent) || isPressing.has(target))
39
+ if (!isValidPressEvent(startEvent) || isPressing.has(target))
41
40
  return;
42
41
  isPressing.add(target);
43
- capturePointer(startEvent, "set");
44
42
  const onPressEnd = onPressStart(target, startEvent);
45
43
  const onPointerEnd = (endEvent, success) => {
46
- target.removeEventListener("pointerup", onPointerUp);
47
- target.removeEventListener("pointercancel", onPointerCancel);
48
- capturePointer(endEvent, "release");
44
+ window.removeEventListener("pointerup", onPointerUp);
45
+ window.removeEventListener("pointercancel", onPointerCancel);
49
46
  if (!isValidPressEvent(endEvent) || !isPressing.has(target)) {
50
47
  return;
51
48
  }
@@ -55,53 +52,29 @@ function press(targetOrSelector, onPressStart, options = {}) {
55
52
  }
56
53
  };
57
54
  const onPointerUp = (upEvent) => {
58
- const isOutside = !upEvent.isTrusted
59
- ? false
60
- : checkOutside(upEvent, target instanceof Element
61
- ? target.getBoundingClientRect()
62
- : {
63
- left: 0,
64
- top: 0,
65
- right: window.innerWidth,
66
- bottom: window.innerHeight,
67
- });
68
- if (isOutside) {
69
- onPointerEnd(upEvent, false);
70
- }
71
- else {
72
- onPointerEnd(upEvent, !(target instanceof Element) ||
73
- isNodeOrChild(target, upEvent.target));
74
- }
55
+ onPointerEnd(upEvent, target === window ||
56
+ target === document ||
57
+ options.useGlobalTarget ||
58
+ isNodeOrChild(target, upEvent.target));
75
59
  };
76
60
  const onPointerCancel = (cancelEvent) => {
77
61
  onPointerEnd(cancelEvent, false);
78
62
  };
79
- target.addEventListener("pointerup", onPointerUp, eventOptions);
80
- target.addEventListener("pointercancel", onPointerCancel, eventOptions);
81
- target.addEventListener("lostpointercapture", onPointerCancel, eventOptions);
63
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
64
+ window.addEventListener("pointercancel", onPointerCancel, eventOptions);
82
65
  };
83
66
  targets.forEach((target) => {
84
- target = options.useGlobalTarget ? window : target;
85
- let canAddKeyboardAccessibility = false;
67
+ const pointerDownTarget = options.useGlobalTarget ? window : target;
68
+ pointerDownTarget.addEventListener("pointerdown", startPress, eventOptions);
86
69
  if (target instanceof HTMLElement) {
87
- canAddKeyboardAccessibility = true;
70
+ target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
88
71
  if (!isElementKeyboardAccessible(target) &&
89
- target.getAttribute("tabindex") === null) {
72
+ target.tabIndex === null) {
90
73
  target.tabIndex = 0;
91
74
  }
92
75
  }
93
- target.addEventListener("pointerdown", startPress, eventOptions);
94
- if (canAddKeyboardAccessibility) {
95
- target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
96
- }
97
76
  });
98
77
  return cancelEvents;
99
78
  }
100
- function checkOutside(event, rect) {
101
- return (event.clientX < rect.left ||
102
- event.clientX > rect.right ||
103
- event.clientY < rect.top ||
104
- event.clientY > rect.bottom);
105
- }
106
79
 
107
80
  export { press };
package/dist/es/index.mjs CHANGED
@@ -15,7 +15,6 @@ export { isDragActive, isDragging } from './gestures/drag/state/is-active.mjs';
15
15
  export { setDragLock } from './gestures/drag/state/set-active.mjs';
16
16
  export { hover } from './gestures/hover.mjs';
17
17
  export { press } from './gestures/press/index.mjs';
18
- export { capturePointer } from './gestures/utils/capture-pointer.mjs';
19
18
  export { isNodeOrChild } from './gestures/utils/is-node-or-child.mjs';
20
19
  export { isPrimaryPointer } from './gestures/utils/is-primary-pointer.mjs';
21
20
  export { recordStats } from './stats/index.mjs';
@@ -30,7 +30,7 @@ class MotionValue {
30
30
  * This will be replaced by the build step with the latest version number.
31
31
  * When MotionValues are provided to motion components, warn if versions are mixed.
32
32
  */
33
- this.version = "12.6.0";
33
+ this.version = "12.6.3-alpha.0";
34
34
  /**
35
35
  * Tracks whether this value can output a velocity. Currently this is only true
36
36
  * if the value is numerical, but we might be able to widen the scope here and support
package/dist/index.d.ts CHANGED
@@ -726,8 +726,6 @@ interface PointerEventOptions extends EventOptions {
726
726
  */
727
727
  declare function press(targetOrSelector: ElementOrSelector, onPressStart: OnPressStartEvent, options?: PointerEventOptions): VoidFunction;
728
728
 
729
- declare function capturePointer(event: PointerEvent, action: "set" | "release"): void;
730
-
731
729
  /**
732
730
  * Recursively traverse up the tree to check whether the provided child node
733
731
  * is the parent or a descendant of it.
@@ -1070,4 +1068,4 @@ declare class ViewTransitionBuilder {
1070
1068
  }
1071
1069
  declare function animateView(update: () => void | Promise<void>, defaultOptions?: ViewTransitionOptions): ViewTransitionBuilder;
1072
1070
 
1073
- export { type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithFinished, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type Batcher, type BezierDefinition, type CSSStyleDeclarationWithTransform, type CancelProcess, type DOMKeyframesDefinition, type DecayOptions, type Driver, type DriverControls, type DurationSpringOptions, type DynamicOption, type Easing, type EasingDefinition, type EasingFunction, type EasingModifier, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, GroupPlaybackControls, type InactiveStatsBuffer, type InertiaOptions, type KeyframeGenerator, type KeyframeOptions, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, NativeAnimationControls, type OnHoverEndEvent, type OnHoverStartEvent, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RepeatType, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TransformProperties, type Transformer, type Transition, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationTransition, type ValueKeyframe, type ValueKeyframesDefinition, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, activeAnimations, animateView, attachTimeline, calcGeneratorDuration, cancelFrame, cancelMicrotask, capturePointer, collectMotionValues, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, frame, frameData, frameSteps, generateLinearEasing, getValueTransition, hover, isBezierDefinition, isDragActive, isDragging, isGenerator, isNodeOrChild, isPrimaryPointer, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, microtask, motionValue, press, recordStats, resolveElements, setDragLock, statsBuffer, supportedWaapiEasing, supportsFlags, supportsLinearEasing, supportsScrollTimeline, time };
1071
+ export { type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithFinished, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type Batcher, type BezierDefinition, type CSSStyleDeclarationWithTransform, type CancelProcess, type DOMKeyframesDefinition, type DecayOptions, type Driver, type DriverControls, type DurationSpringOptions, type DynamicOption, type Easing, type EasingDefinition, type EasingFunction, type EasingModifier, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, GroupPlaybackControls, type InactiveStatsBuffer, type InertiaOptions, type KeyframeGenerator, type KeyframeOptions, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, NativeAnimationControls, type OnHoverEndEvent, type OnHoverStartEvent, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RepeatType, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TransformProperties, type Transformer, type Transition, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationTransition, type ValueKeyframe, type ValueKeyframesDefinition, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, activeAnimations, animateView, attachTimeline, calcGeneratorDuration, cancelFrame, cancelMicrotask, collectMotionValues, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, frame, frameData, frameSteps, generateLinearEasing, getValueTransition, hover, isBezierDefinition, isDragActive, isDragging, isGenerator, isNodeOrChild, isPrimaryPointer, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, microtask, motionValue, press, recordStats, resolveElements, setDragLock, statsBuffer, supportedWaapiEasing, supportsFlags, supportsLinearEasing, supportsScrollTimeline, time };
@@ -597,18 +597,6 @@
597
597
  return cancel;
598
598
  }
599
599
 
600
- function capturePointer(event, action) {
601
- const actionName = `${action}PointerCapture`;
602
- if (event.target instanceof Element &&
603
- actionName in event.target &&
604
- event.pointerId !== undefined) {
605
- try {
606
- event.target[actionName](event.pointerId);
607
- }
608
- catch (e) { }
609
- }
610
- }
611
-
612
600
  /**
613
601
  * Recursively traverse up the tree to check whether the provided child node
614
602
  * is the parent or a descendant of it.
@@ -724,15 +712,13 @@
724
712
  const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
725
713
  const startPress = (startEvent) => {
726
714
  const target = startEvent.currentTarget;
727
- if (!target || !isValidPressEvent(startEvent) || isPressing.has(target))
715
+ if (!isValidPressEvent(startEvent) || isPressing.has(target))
728
716
  return;
729
717
  isPressing.add(target);
730
- capturePointer(startEvent, "set");
731
718
  const onPressEnd = onPressStart(target, startEvent);
732
719
  const onPointerEnd = (endEvent, success) => {
733
- target.removeEventListener("pointerup", onPointerUp);
734
- target.removeEventListener("pointercancel", onPointerCancel);
735
- capturePointer(endEvent, "release");
720
+ window.removeEventListener("pointerup", onPointerUp);
721
+ window.removeEventListener("pointercancel", onPointerCancel);
736
722
  if (!isValidPressEvent(endEvent) || !isPressing.has(target)) {
737
723
  return;
738
724
  }
@@ -742,54 +728,30 @@
742
728
  }
743
729
  };
744
730
  const onPointerUp = (upEvent) => {
745
- const isOutside = !upEvent.isTrusted
746
- ? false
747
- : checkOutside(upEvent, target instanceof Element
748
- ? target.getBoundingClientRect()
749
- : {
750
- left: 0,
751
- top: 0,
752
- right: window.innerWidth,
753
- bottom: window.innerHeight,
754
- });
755
- if (isOutside) {
756
- onPointerEnd(upEvent, false);
757
- }
758
- else {
759
- onPointerEnd(upEvent, !(target instanceof Element) ||
760
- isNodeOrChild(target, upEvent.target));
761
- }
731
+ onPointerEnd(upEvent, target === window ||
732
+ target === document ||
733
+ options.useGlobalTarget ||
734
+ isNodeOrChild(target, upEvent.target));
762
735
  };
763
736
  const onPointerCancel = (cancelEvent) => {
764
737
  onPointerEnd(cancelEvent, false);
765
738
  };
766
- target.addEventListener("pointerup", onPointerUp, eventOptions);
767
- target.addEventListener("pointercancel", onPointerCancel, eventOptions);
768
- target.addEventListener("lostpointercapture", onPointerCancel, eventOptions);
739
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
740
+ window.addEventListener("pointercancel", onPointerCancel, eventOptions);
769
741
  };
770
742
  targets.forEach((target) => {
771
- target = options.useGlobalTarget ? window : target;
772
- let canAddKeyboardAccessibility = false;
743
+ const pointerDownTarget = options.useGlobalTarget ? window : target;
744
+ pointerDownTarget.addEventListener("pointerdown", startPress, eventOptions);
773
745
  if (target instanceof HTMLElement) {
774
- canAddKeyboardAccessibility = true;
746
+ target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
775
747
  if (!isElementKeyboardAccessible(target) &&
776
- target.getAttribute("tabindex") === null) {
748
+ target.tabIndex === null) {
777
749
  target.tabIndex = 0;
778
750
  }
779
751
  }
780
- target.addEventListener("pointerdown", startPress, eventOptions);
781
- if (canAddKeyboardAccessibility) {
782
- target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
783
- }
784
752
  });
785
753
  return cancelEvents;
786
754
  }
787
- function checkOutside(event, rect) {
788
- return (event.clientX < rect.left ||
789
- event.clientX > rect.right ||
790
- event.clientY < rect.top ||
791
- event.clientY > rect.bottom);
792
- }
793
755
 
794
756
  const activeAnimations = {
795
757
  layout: 0,
@@ -933,7 +895,7 @@
933
895
  * This will be replaced by the build step with the latest version number.
934
896
  * When MotionValues are provided to motion components, warn if versions are mixed.
935
897
  */
936
- this.version = "12.6.0";
898
+ this.version = "12.6.3-alpha.0";
937
899
  /**
938
900
  * Tracks whether this value can output a velocity. Currently this is only true
939
901
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -1585,7 +1547,6 @@
1585
1547
  exports.calcGeneratorDuration = calcGeneratorDuration;
1586
1548
  exports.cancelFrame = cancelFrame;
1587
1549
  exports.cancelMicrotask = cancelMicrotask;
1588
- exports.capturePointer = capturePointer;
1589
1550
  exports.collectMotionValues = collectMotionValues;
1590
1551
  exports.createGeneratorEasing = createGeneratorEasing;
1591
1552
  exports.createRenderBatcher = createRenderBatcher;
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("motion-utils")):"function"==typeof define&&define.amd?define(["exports","motion-utils"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).MotionDom={},t.MotionUtils)}(this,(function(t,e){"use strict";const n=e.memo(()=>void 0!==window.ScrollTimeline);class i{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const i=this.animations.map(i=>n()&&i.attachTimeline?i.attachTimeline(t):"function"==typeof e?e(i):void 0);return()=>{i.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach(e=>e[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function a(t,e){return t?t[e]||t.default||t:void 0}function s(t){let e=0;let n=t.next(e);for(;!n.done&&e<2e4;)e+=50,n=t.next(e);return e>=2e4?1/0:e}function o(t,n=100,i){const a=i({...t,keyframes:[0,n]}),o=Math.min(s(a),2e4);return{type:"keyframes",ease:t=>a.next(o*t).value/n,duration:e.millisecondsToSeconds(o)}}function r(t){return"function"==typeof t}function c(t,e){t.timeline=e,t.onfinish=null}class l{constructor(t){this.animation=t}get duration(){var t,n,i;const a=(null===(n=null===(t=this.animation)||void 0===t?void 0:t.effect)||void 0===n?void 0:n.getComputedTiming().duration)||(null===(i=this.options)||void 0===i?void 0:i.duration)||300;return e.millisecondsToSeconds(Number(a))}get time(){var t;return this.animation?e.millisecondsToSeconds((null===(t=this.animation)||void 0===t?void 0:t.currentTime)||0):0}set time(t){this.animation&&(this.animation.currentTime=e.secondsToMilliseconds(t))}get speed(){return this.animation?this.animation.playbackRate:1}set speed(t){this.animation&&(this.animation.playbackRate=t)}get state(){return this.animation?this.animation.playState:"finished"}get startTime(){return this.animation?this.animation.startTime:null}get finished(){return this.animation?this.animation.finished:Promise.resolve()}play(){this.animation&&this.animation.play()}pause(){this.animation&&this.animation.pause()}stop(){this.animation&&"idle"!==this.state&&"finished"!==this.state&&(this.animation.commitStyles&&this.animation.commitStyles(),this.cancel())}flatten(){var t,e;this.animation&&(null===(t=this.options)||void 0===t?void 0:t.allowFlatten)&&(null===(e=this.animation.effect)||void 0===e||e.updateTiming({easing:"linear"}))}attachTimeline(t){return this.animation&&c(this.animation,t),e.noop}complete(){this.animation&&this.animation.finish()}cancel(){try{this.animation&&this.animation.cancel()}catch(t){}}}const u=t=>Array.isArray(t)&&"number"==typeof t[0],d={linearEasing:void 0};function h(t,n){const i=e.memo(t);return()=>{var t;return null!==(t=d[n])&&void 0!==t?t:i()}}const m=h(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),p=(t,n,i=10)=>{let a="";const s=Math.max(Math.round(n/i),2);for(let n=0;n<s;n++)a+=t(e.progress(0,s-1,n))+", ";return`linear(${a.substring(0,a.length-2)})`};const f=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,v={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:f([0,.65,.55,1]),circOut:f([.55,0,1,.45]),backIn:f([.31,.01,.66,-.59]),backOut:f([.33,1.53,.69,.99])};function y(t,e){return t?"function"==typeof t&&m()?p(t,e):u(t)?f(t):Array.isArray(t)?t.map(t=>y(t,e)||v.easeOut):v[t]:void 0}const g=["read","resolveKeyframes","update","preRender","render","postRender"],w={value:null,addProjectionMetrics:null};function T(t,n){let i=!1,a=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>i=!0,r=g.reduce((t,e)=>(t[e]=function(t,e){let n=new Set,i=new Set,a=!1,s=!1;const o=new WeakSet;let r={delta:0,timestamp:0,isProcessing:!1},c=0;function l(e){o.has(e)&&(u.schedule(e),t()),c++,e(r)}const u={schedule:(t,e=!1,s=!1)=>{const r=s&&a?n:i;return e&&o.add(t),r.has(t)||r.add(t),t},cancel:t=>{i.delete(t),o.delete(t)},process:t=>{r=t,a?s=!0:(a=!0,[n,i]=[i,n],n.forEach(l),e&&w.value&&w.value.frameloop[e].push(c),c=0,n.clear(),a=!1,s&&(s=!1,u.process(t)))}};return u}(o,n?e:void 0),t),{}),{read:c,resolveKeyframes:l,update:u,preRender:d,render:h,postRender:m}=r,p=()=>{const o=e.MotionGlobalConfig.useManualTiming?s.timestamp:performance.now();i=!1,e.MotionGlobalConfig.useManualTiming||(s.delta=a?1e3/60:Math.max(Math.min(o-s.timestamp,40),1)),s.timestamp=o,s.isProcessing=!0,c.process(s),l.process(s),u.process(s),d.process(s),h.process(s),m.process(s),s.isProcessing=!1,i&&n&&(a=!1,t(p))};return{schedule:g.reduce((e,n)=>{const o=r[n];return e[n]=(e,n=!1,r=!1)=>(i||(i=!0,a=!0,s.isProcessing||t(p)),o.schedule(e,n,r)),e},{}),cancel:t=>{for(let e=0;e<g.length;e++)r[g[e]].cancel(t)},state:s,steps:r}}const{schedule:E,cancel:A,state:P,steps:b}=T("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:e.noop,!0),{schedule:x,cancel:M}=T(queueMicrotask,!1);let k;function S(){k=void 0}const C={now:()=>(void 0===k&&C.set(P.isProcessing||e.MotionGlobalConfig.useManualTiming?P.timestamp:performance.now()),k),set:t=>{k=t,queueMicrotask(S)}},L={x:!1,y:!1};function R(){return L.x||L.y}function V(t,e,n){var i;if(t instanceof EventTarget)return[t];if("string"==typeof t){let a=document;e&&(a=e.current);const s=null!==(i=null==n?void 0:n[t])&&void 0!==i?i:a.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t)}function j(t,e){const n=V(t),i=new AbortController;return[n,{passive:!0,...e,signal:i.signal},()=>i.abort()]}function F(t){return!("touch"===t.pointerType||R())}function D(t,e){const n=e+"PointerCapture";if(t.target instanceof Element&&n in t.target&&void 0!==t.pointerId)try{t.target[n](t.pointerId)}catch(t){}}const N=(t,e)=>!!e&&(t===e||N(t,e.parentElement)),O=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,B=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const I=new WeakSet;function G(t){return e=>{"Enter"===e.key&&t(e)}}function $(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function q(t){return O(t)&&!R()}const K={layout:0,mainThread:0,waapi:0};function U(){const{value:t}=w;null!==t?(t.frameloop.rate.push(P.delta),t.animations.mainThread.push(K.mainThread),t.animations.waapi.push(K.waapi),t.animations.layout.push(K.layout)):A(U)}function W(t){return t.reduce((t,e)=>t+e,0)/t.length}function z(t,e=W){return 0===t.length?{min:0,max:0,avg:0}:{min:Math.min(...t),max:Math.max(...t),avg:e(t)}}const X=t=>Math.round(1e3/t);function H(){w.value=null,w.addProjectionMetrics=null}function Y(){const{value:t}=w;if(!t)throw new Error("Stats are not being measured");H(),A(U);const e={frameloop:{rate:z(t.frameloop.rate),read:z(t.frameloop.read),resolveKeyframes:z(t.frameloop.resolveKeyframes),update:z(t.frameloop.update),preRender:z(t.frameloop.preRender),render:z(t.frameloop.render),postRender:z(t.frameloop.postRender)},animations:{mainThread:z(t.animations.mainThread),waapi:z(t.animations.waapi),layout:z(t.animations.layout)},layoutProjection:{nodes:z(t.layoutProjection.nodes),calculatedTargetDeltas:z(t.layoutProjection.calculatedTargetDeltas),calculatedProjections:z(t.layoutProjection.calculatedProjections)}},{rate:n}=e.frameloop;return n.min=X(n.min),n.max=X(n.max),n.avg=X(n.avg),[n.min,n.max]=[n.max,n.min],e}const J={current:void 0};class Q{constructor(t,e={}){this.version="12.6.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const n=C.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),e&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=C.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new e.SubscriptionManager);const i=this.events[t].add(n);return"change"===t?()=>{i(),E.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,n){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return J.current&&J.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=C.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,30);return e.velocityPerSecond(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(e=>{this.hasAnimated=!0,this.animation=t(e),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Z(t){var n;if(r(t.type)){const n=o(t,100,t.type);t.ease=m()?n.ease:"easeOut",t.duration=e.secondsToMilliseconds(n.duration),t.type="keyframes"}else t.duration=e.secondsToMilliseconds(null!==(n=t.duration)&&void 0!==n?n:.3),t.ease=t.ease||"easeOut"}class _ extends l{constructor(t,n,i,a,s){const o=function(t,n,i){var a;const s={},o={fill:"both",easing:"linear",composite:"replace"};o.delay=e.secondsToMilliseconds(null!==(a=i.delay)&&void 0!==a?a:0),Z(i),o.duration=i.duration;const{ease:r,times:c}=i;c&&(s.offset=c),s[t]=n;const l=y(r,i.duration);return Array.isArray(l)?s.easing=l:o.easing=l,{keyframes:s,options:o}}(i,a,s);super(t.animate(o.keyframes,{pseudoElement:n,...o.options}))}}function tt(t){return"layout"===t?"group":"enter"===t||"new"===t?"new":"exit"===t||"old"===t?"old":"group"}let et={},nt=null;const it=(t,e)=>{et[t]=e},at=()=>{nt||(nt=document.createElement("style"),nt.id="motion-view");let t="";for(const e in et){const n=et[e];t+=e+" {\n";for(const[e,i]of Object.entries(n))t+=` ${e}: ${i};\n`;t+="}\n"}nt.textContent=t,document.head.appendChild(nt),et={}},st=()=>{nt&&nt.parentElement&&nt.parentElement.removeChild(nt)};function ot(t){const e=t.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);return e?{layer:e[2],type:e[1]}:null}function rt(t){var e;const{effect:n}=t;return!!n&&(n.target===document.documentElement&&(null===(e=n.pseudoElement)||void 0===e?void 0:e.startsWith("::view-transition")))}const ct=["layout","enter","exit","new","old"];function lt(t){const{update:n,targets:s,options:o}=t;if(!document.startViewTransition)return new Promise(async t=>{await n(),t(new i([]))});(function(t,e){return e.has(t)&&Object.keys(e.get(t)).length>0})("root",s)||it(":root",{"view-transition-name":"none"}),it("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)",{"animation-timing-function":"linear !important"}),at();const r=document.startViewTransition(async()=>{await n()});return r.finished.finally(()=>{st()}),new Promise(t=>{r.ready.then(()=>{var n;const r=document.getAnimations().filter(rt),c=[];s.forEach((t,e)=>{for(const n of ct){if(!t[n])continue;const{keyframes:i,options:s}=t[n];for(let[t,r]of Object.entries(i)){if(!r)continue;const i={...a(o,t),...a(s,t)},l=tt(n);if("opacity"===t&&!Array.isArray(r)){r=["new"===l?0:1,r]}"function"==typeof i.delay&&(i.delay=i.delay(0,1));const u=new _(document.documentElement,`::view-transition-${l}(${e})`,t,r,i);c.push(u)}}});for(const t of r){if("finished"===t.playState)continue;const{effect:i}=t;if(!(i&&i instanceof KeyframeEffect))continue;const{pseudoElement:r}=i;if(!r)continue;const u=ot(r);if(!u)continue;const d=s.get(u.layer);if(d)ut(d,"enter")&&ut(d,"exit")&&i.getKeyframes().some(t=>t.mixBlendMode)?c.push(new l(t)):t.cancel();else{const s="group"===u.type?"layout":"",r={...a(o,s)};Z(r);const d=y(r.ease,r.duration);i.updateTiming({delay:e.secondsToMilliseconds(null!==(n=r.delay)&&void 0!==n?n:0),duration:r.duration,easing:d}),c.push(new l(t))}}t(new i(c))})})}function ut(t,e){var n;return null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.keyframes.opacity}let dt=[],ht=null;function mt(){ht=null;const[t]=dt;var n;t&&(n=t,e.removeItem(dt,n),ht=n,lt(n).then(t=>{n.notifyReady(t),t.finished.finally(mt)}))}function pt(){var t;for(let t=dt.length-1;t>=0;t--){const e=dt[t],{interrupt:n}=e.options;if("immediate"===n){const n=dt.slice(0,t+1).map(t=>t.update),i=dt.slice(t+1);e.update=()=>{n.forEach(t=>t())},dt=[e,...i];break}}ht&&"immediate"!==(null===(t=dt[0])||void 0===t?void 0:t.options.interrupt)||mt()}class ft{constructor(t,n={}){var i;this.currentTarget="root",this.targets=new Map,this.notifyReady=e.noop,this.readyPromise=new Promise(t=>{this.notifyReady=t}),this.update=t,this.options={interrupt:"wait",...n},i=this,dt.push(i),x.render(pt)}get(t){return this.currentTarget=t,this}layout(t,e){return this.updateTarget("layout",t,e),this}new(t,e){return this.updateTarget("new",t,e),this}old(t,e){return this.updateTarget("old",t,e),this}enter(t,e){return this.updateTarget("enter",t,e),this}exit(t,e){return this.updateTarget("exit",t,e),this}crossfade(t){return this.updateTarget("enter",{opacity:1},t),this.updateTarget("exit",{opacity:0},t),this}updateTarget(t,e,n={}){const{currentTarget:i,targets:a}=this;a.has(i)||a.set(i,{});a.get(i)[t]={keyframes:e,options:n}}then(t,e){return this.readyPromise.then(t,e)}}t.GroupPlaybackControls=class extends i{then(t,e){return Promise.all(this.animations).then(t).catch(e)}},t.MotionValue=Q,t.NativeAnimationControls=l,t.ViewTransitionBuilder=ft,t.activeAnimations=K,t.animateView=function(t,e={}){return new ft(t,e)},t.attachTimeline=c,t.calcGeneratorDuration=s,t.cancelFrame=A,t.cancelMicrotask=M,t.capturePointer=D,t.collectMotionValues=J,t.createGeneratorEasing=o,t.createRenderBatcher=T,t.cubicBezierAsString=f,t.frame=E,t.frameData=P,t.frameSteps=b,t.generateLinearEasing=p,t.getValueTransition=a,t.hover=function(t,e,n={}){const[i,a,s]=j(t,n),o=t=>{if(!F(t))return;const{target:n}=t,i=e(n,t);if("function"!=typeof i||!n)return;const s=t=>{F(t)&&(i(t),n.removeEventListener("pointerleave",s))};n.addEventListener("pointerleave",s,a)};return i.forEach(t=>{t.addEventListener("pointerenter",o,a)}),s},t.isBezierDefinition=u,t.isDragActive=R,t.isDragging=L,t.isGenerator=r,t.isNodeOrChild=N,t.isPrimaryPointer=O,t.isWaapiSupportedEasing=function t(e){return Boolean("function"==typeof e&&m()||!e||"string"==typeof e&&(e in v||m())||u(e)||Array.isArray(e)&&e.every(t))},t.mapEasingToNativeEasing=y,t.maxGeneratorDuration=2e4,t.microtask=x,t.motionValue=function(t,e){return new Q(t,e)},t.press=function(t,e,n={}){const[i,a,s]=j(t,n),o=t=>{const n=t.currentTarget;if(!n||!q(t)||I.has(n))return;I.add(n),D(t,"set");const i=e(n,t),s=(t,e)=>{n.removeEventListener("pointerup",o),n.removeEventListener("pointercancel",r),D(t,"release"),q(t)&&I.has(n)&&(I.delete(n),"function"==typeof i&&i(t,{success:e}))},o=t=>{const e=!!t.isTrusted&&(i=t,a=n instanceof Element?n.getBoundingClientRect():{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},i.clientX<a.left||i.clientX>a.right||i.clientY<a.top||i.clientY>a.bottom);var i,a;s(t,!e&&(!(n instanceof Element)||N(n,t.target)))},r=t=>{s(t,!1)};n.addEventListener("pointerup",o,a),n.addEventListener("pointercancel",r,a),n.addEventListener("lostpointercapture",r,a)};return i.forEach(t=>{let e=!1;var i;(t=n.useGlobalTarget?window:t)instanceof HTMLElement&&(e=!0,i=t,B.has(i.tagName)||-1!==i.tabIndex||null!==t.getAttribute("tabindex")||(t.tabIndex=0)),t.addEventListener("pointerdown",o,a),e&&t.addEventListener("focus",t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const i=G(()=>{if(I.has(n))return;$(n,"down");const t=G(()=>{$(n,"up")});n.addEventListener("keyup",t,e),n.addEventListener("blur",()=>$(n,"cancel"),e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)})(t,a),a)}),s},t.recordStats=function(){if(w.value)throw H(),new Error("Stats are already being measured");const t=w;return t.value={frameloop:{rate:[],read:[],resolveKeyframes:[],update:[],preRender:[],render:[],postRender:[]},animations:{mainThread:[],waapi:[],layout:[]},layoutProjection:{nodes:[],calculatedTargetDeltas:[],calculatedProjections:[]}},t.addProjectionMetrics=e=>{const{layoutProjection:n}=t.value;n.nodes.push(e.nodes),n.calculatedTargetDeltas.push(e.calculatedTargetDeltas),n.calculatedProjections.push(e.calculatedProjections)},E.postRender(U,!0),Y},t.resolveElements=V,t.setDragLock=function(t){return"x"===t||"y"===t?L[t]?null:(L[t]=!0,()=>{L[t]=!1}):L.x||L.y?null:(L.x=L.y=!0,()=>{L.x=L.y=!1})},t.statsBuffer=w,t.supportedWaapiEasing=v,t.supportsFlags=d,t.supportsLinearEasing=m,t.supportsScrollTimeline=n,t.time=C}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("motion-utils")):"function"==typeof define&&define.amd?define(["exports","motion-utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MotionDom={},e.MotionUtils)}(this,(function(e,t){"use strict";const n=t.memo(()=>void 0!==window.ScrollTimeline);class i{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>"finished"in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let n=0;n<this.animations.length;n++)this.animations[n][e]=t}attachTimeline(e,t){const i=this.animations.map(i=>n()&&i.attachTimeline?i.attachTimeline(e):"function"==typeof t?t(i):void 0);return()=>{i.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let t=0;t<this.animations.length;t++)e=Math.max(e,this.animations[t].duration);return e}runAll(e){this.animations.forEach(t=>t[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function a(e,t){return e?e[t]||e.default||e:void 0}function s(e){let t=0;let n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function o(e,n=100,i){const a=i({...e,keyframes:[0,n]}),o=Math.min(s(a),2e4);return{type:"keyframes",ease:e=>a.next(o*e).value/n,duration:t.millisecondsToSeconds(o)}}function r(e){return"function"==typeof e}function c(e,t){e.timeline=t,e.onfinish=null}class u{constructor(e){this.animation=e}get duration(){var e,n,i;const a=(null===(n=null===(e=this.animation)||void 0===e?void 0:e.effect)||void 0===n?void 0:n.getComputedTiming().duration)||(null===(i=this.options)||void 0===i?void 0:i.duration)||300;return t.millisecondsToSeconds(Number(a))}get time(){var e;return this.animation?t.millisecondsToSeconds((null===(e=this.animation)||void 0===e?void 0:e.currentTime)||0):0}set time(e){this.animation&&(this.animation.currentTime=t.secondsToMilliseconds(e))}get speed(){return this.animation?this.animation.playbackRate:1}set speed(e){this.animation&&(this.animation.playbackRate=e)}get state(){return this.animation?this.animation.playState:"finished"}get startTime(){return this.animation?this.animation.startTime:null}get finished(){return this.animation?this.animation.finished:Promise.resolve()}play(){this.animation&&this.animation.play()}pause(){this.animation&&this.animation.pause()}stop(){this.animation&&"idle"!==this.state&&"finished"!==this.state&&(this.animation.commitStyles&&this.animation.commitStyles(),this.cancel())}flatten(){var e,t;this.animation&&(null===(e=this.options)||void 0===e?void 0:e.allowFlatten)&&(null===(t=this.animation.effect)||void 0===t||t.updateTiming({easing:"linear"}))}attachTimeline(e){return this.animation&&c(this.animation,e),t.noop}complete(){this.animation&&this.animation.finish()}cancel(){try{this.animation&&this.animation.cancel()}catch(e){}}}const l=e=>Array.isArray(e)&&"number"==typeof e[0],d={linearEasing:void 0};function h(e,n){const i=t.memo(e);return()=>{var e;return null!==(e=d[n])&&void 0!==e?e:i()}}const m=h(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),p=(e,n,i=10)=>{let a="";const s=Math.max(Math.round(n/i),2);for(let n=0;n<s;n++)a+=e(t.progress(0,s-1,n))+", ";return`linear(${a.substring(0,a.length-2)})`};const f=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,v={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:f([0,.65,.55,1]),circOut:f([.55,0,1,.45]),backIn:f([.31,.01,.66,-.59]),backOut:f([.33,1.53,.69,.99])};function y(e,t){return e?"function"==typeof e&&m()?p(e,t):l(e)?f(e):Array.isArray(e)?e.map(e=>y(e,t)||v.easeOut):v[e]:void 0}const g=["read","resolveKeyframes","update","preRender","render","postRender"],w={value:null,addProjectionMetrics:null};function T(e,n){let i=!1,a=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>i=!0,r=g.reduce((e,t)=>(e[t]=function(e,t){let n=new Set,i=new Set,a=!1,s=!1;const o=new WeakSet;let r={delta:0,timestamp:0,isProcessing:!1},c=0;function u(t){o.has(t)&&(l.schedule(t),e()),c++,t(r)}const l={schedule:(e,t=!1,s=!1)=>{const r=s&&a?n:i;return t&&o.add(e),r.has(e)||r.add(e),e},cancel:e=>{i.delete(e),o.delete(e)},process:e=>{r=e,a?s=!0:(a=!0,[n,i]=[i,n],n.forEach(u),t&&w.value&&w.value.frameloop[t].push(c),c=0,n.clear(),a=!1,s&&(s=!1,l.process(e)))}};return l}(o,n?t:void 0),e),{}),{read:c,resolveKeyframes:u,update:l,preRender:d,render:h,postRender:m}=r,p=()=>{const o=t.MotionGlobalConfig.useManualTiming?s.timestamp:performance.now();i=!1,t.MotionGlobalConfig.useManualTiming||(s.delta=a?1e3/60:Math.max(Math.min(o-s.timestamp,40),1)),s.timestamp=o,s.isProcessing=!0,c.process(s),u.process(s),l.process(s),d.process(s),h.process(s),m.process(s),s.isProcessing=!1,i&&n&&(a=!1,e(p))};return{schedule:g.reduce((t,n)=>{const o=r[n];return t[n]=(t,n=!1,r=!1)=>(i||(i=!0,a=!0,s.isProcessing||e(p)),o.schedule(t,n,r)),t},{}),cancel:e=>{for(let t=0;t<g.length;t++)r[g[t]].cancel(e)},state:s,steps:r}}const{schedule:E,cancel:A,state:P,steps:b}=T("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:t.noop,!0),{schedule:x,cancel:M}=T(queueMicrotask,!1);let k;function S(){k=void 0}const L={now:()=>(void 0===k&&L.set(P.isProcessing||t.MotionGlobalConfig.useManualTiming?P.timestamp:performance.now()),k),set:e=>{k=e,queueMicrotask(S)}},V={x:!1,y:!1};function C(){return V.x||V.y}function R(e,t,n){var i;if(e instanceof EventTarget)return[e];if("string"==typeof e){let a=document;t&&(a=t.current);const s=null!==(i=null==n?void 0:n[e])&&void 0!==i?i:a.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e)}function j(e,t){const n=R(e),i=new AbortController;return[n,{passive:!0,...t,signal:i.signal},()=>i.abort()]}function F(e){return!("touch"===e.pointerType||C())}const D=(e,t)=>!!t&&(e===t||D(e,t.parentElement)),N=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary,O=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const G=new WeakSet;function B(e){return t=>{"Enter"===t.key&&e(t)}}function I(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function $(e){return N(e)&&!C()}const q={layout:0,mainThread:0,waapi:0};function K(){const{value:e}=w;null!==e?(e.frameloop.rate.push(P.delta),e.animations.mainThread.push(q.mainThread),e.animations.waapi.push(q.waapi),e.animations.layout.push(q.layout)):A(K)}function U(e){return e.reduce((e,t)=>e+t,0)/e.length}function W(e,t=U){return 0===e.length?{min:0,max:0,avg:0}:{min:Math.min(...e),max:Math.max(...e),avg:t(e)}}const z=e=>Math.round(1e3/e);function H(){w.value=null,w.addProjectionMetrics=null}function X(){const{value:e}=w;if(!e)throw new Error("Stats are not being measured");H(),A(K);const t={frameloop:{rate:W(e.frameloop.rate),read:W(e.frameloop.read),resolveKeyframes:W(e.frameloop.resolveKeyframes),update:W(e.frameloop.update),preRender:W(e.frameloop.preRender),render:W(e.frameloop.render),postRender:W(e.frameloop.postRender)},animations:{mainThread:W(e.animations.mainThread),waapi:W(e.animations.waapi),layout:W(e.animations.layout)},layoutProjection:{nodes:W(e.layoutProjection.nodes),calculatedTargetDeltas:W(e.layoutProjection.calculatedTargetDeltas),calculatedProjections:W(e.layoutProjection.calculatedProjections)}},{rate:n}=t.frameloop;return n.min=z(n.min),n.max=z(n.max),n.avg=z(n.avg),[n.min,n.max]=[n.max,n.min],t}const J={current:void 0};class Q{constructor(e,t={}){this.version="12.6.3-alpha.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(e,t=!0)=>{const n=L.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),t&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=L.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new t.SubscriptionManager);const i=this.events[e].add(n);return"change"===e?()=>{i(),E.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){t&&this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e,t)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return J.current&&J.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=L.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,30);return t.velocityPerSecond(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Y(e){var n;if(r(e.type)){const n=o(e,100,e.type);e.ease=m()?n.ease:"easeOut",e.duration=t.secondsToMilliseconds(n.duration),e.type="keyframes"}else e.duration=t.secondsToMilliseconds(null!==(n=e.duration)&&void 0!==n?n:.3),e.ease=e.ease||"easeOut"}class Z extends u{constructor(e,n,i,a,s){const o=function(e,n,i){var a;const s={},o={fill:"both",easing:"linear",composite:"replace"};o.delay=t.secondsToMilliseconds(null!==(a=i.delay)&&void 0!==a?a:0),Y(i),o.duration=i.duration;const{ease:r,times:c}=i;c&&(s.offset=c),s[e]=n;const u=y(r,i.duration);return Array.isArray(u)?s.easing=u:o.easing=u,{keyframes:s,options:o}}(i,a,s);super(e.animate(o.keyframes,{pseudoElement:n,...o.options}))}}function _(e){return"layout"===e?"group":"enter"===e||"new"===e?"new":"exit"===e||"old"===e?"old":"group"}let ee={},te=null;const ne=(e,t)=>{ee[e]=t},ie=()=>{te||(te=document.createElement("style"),te.id="motion-view");let e="";for(const t in ee){const n=ee[t];e+=t+" {\n";for(const[t,i]of Object.entries(n))e+=` ${t}: ${i};\n`;e+="}\n"}te.textContent=e,document.head.appendChild(te),ee={}},ae=()=>{te&&te.parentElement&&te.parentElement.removeChild(te)};function se(e){const t=e.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);return t?{layer:t[2],type:t[1]}:null}function oe(e){var t;const{effect:n}=e;return!!n&&(n.target===document.documentElement&&(null===(t=n.pseudoElement)||void 0===t?void 0:t.startsWith("::view-transition")))}const re=["layout","enter","exit","new","old"];function ce(e){const{update:n,targets:s,options:o}=e;if(!document.startViewTransition)return new Promise(async e=>{await n(),e(new i([]))});(function(e,t){return t.has(e)&&Object.keys(t.get(e)).length>0})("root",s)||ne(":root",{"view-transition-name":"none"}),ne("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)",{"animation-timing-function":"linear !important"}),ie();const r=document.startViewTransition(async()=>{await n()});return r.finished.finally(()=>{ae()}),new Promise(e=>{r.ready.then(()=>{var n;const r=document.getAnimations().filter(oe),c=[];s.forEach((e,t)=>{for(const n of re){if(!e[n])continue;const{keyframes:i,options:s}=e[n];for(let[e,r]of Object.entries(i)){if(!r)continue;const i={...a(o,e),...a(s,e)},u=_(n);if("opacity"===e&&!Array.isArray(r)){r=["new"===u?0:1,r]}"function"==typeof i.delay&&(i.delay=i.delay(0,1));const l=new Z(document.documentElement,`::view-transition-${u}(${t})`,e,r,i);c.push(l)}}});for(const e of r){if("finished"===e.playState)continue;const{effect:i}=e;if(!(i&&i instanceof KeyframeEffect))continue;const{pseudoElement:r}=i;if(!r)continue;const l=se(r);if(!l)continue;const d=s.get(l.layer);if(d)ue(d,"enter")&&ue(d,"exit")&&i.getKeyframes().some(e=>e.mixBlendMode)?c.push(new u(e)):e.cancel();else{const s="group"===l.type?"layout":"",r={...a(o,s)};Y(r);const d=y(r.ease,r.duration);i.updateTiming({delay:t.secondsToMilliseconds(null!==(n=r.delay)&&void 0!==n?n:0),duration:r.duration,easing:d}),c.push(new u(e))}}e(new i(c))})})}function ue(e,t){var n;return null===(n=null==e?void 0:e[t])||void 0===n?void 0:n.keyframes.opacity}let le=[],de=null;function he(){de=null;const[e]=le;var n;e&&(n=e,t.removeItem(le,n),de=n,ce(n).then(e=>{n.notifyReady(e),e.finished.finally(he)}))}function me(){var e;for(let e=le.length-1;e>=0;e--){const t=le[e],{interrupt:n}=t.options;if("immediate"===n){const n=le.slice(0,e+1).map(e=>e.update),i=le.slice(e+1);t.update=()=>{n.forEach(e=>e())},le=[t,...i];break}}de&&"immediate"!==(null===(e=le[0])||void 0===e?void 0:e.options.interrupt)||he()}class pe{constructor(e,n={}){var i;this.currentTarget="root",this.targets=new Map,this.notifyReady=t.noop,this.readyPromise=new Promise(e=>{this.notifyReady=e}),this.update=e,this.options={interrupt:"wait",...n},i=this,le.push(i),x.render(me)}get(e){return this.currentTarget=e,this}layout(e,t){return this.updateTarget("layout",e,t),this}new(e,t){return this.updateTarget("new",e,t),this}old(e,t){return this.updateTarget("old",e,t),this}enter(e,t){return this.updateTarget("enter",e,t),this}exit(e,t){return this.updateTarget("exit",e,t),this}crossfade(e){return this.updateTarget("enter",{opacity:1},e),this.updateTarget("exit",{opacity:0},e),this}updateTarget(e,t,n={}){const{currentTarget:i,targets:a}=this;a.has(i)||a.set(i,{});a.get(i)[e]={keyframes:t,options:n}}then(e,t){return this.readyPromise.then(e,t)}}e.GroupPlaybackControls=class extends i{then(e,t){return Promise.all(this.animations).then(e).catch(t)}},e.MotionValue=Q,e.NativeAnimationControls=u,e.ViewTransitionBuilder=pe,e.activeAnimations=q,e.animateView=function(e,t={}){return new pe(e,t)},e.attachTimeline=c,e.calcGeneratorDuration=s,e.cancelFrame=A,e.cancelMicrotask=M,e.collectMotionValues=J,e.createGeneratorEasing=o,e.createRenderBatcher=T,e.cubicBezierAsString=f,e.frame=E,e.frameData=P,e.frameSteps=b,e.generateLinearEasing=p,e.getValueTransition=a,e.hover=function(e,t,n={}){const[i,a,s]=j(e,n),o=e=>{if(!F(e))return;const{target:n}=e,i=t(n,e);if("function"!=typeof i||!n)return;const s=e=>{F(e)&&(i(e),n.removeEventListener("pointerleave",s))};n.addEventListener("pointerleave",s,a)};return i.forEach(e=>{e.addEventListener("pointerenter",o,a)}),s},e.isBezierDefinition=l,e.isDragActive=C,e.isDragging=V,e.isGenerator=r,e.isNodeOrChild=D,e.isPrimaryPointer=N,e.isWaapiSupportedEasing=function e(t){return Boolean("function"==typeof t&&m()||!t||"string"==typeof t&&(t in v||m())||l(t)||Array.isArray(t)&&t.every(e))},e.mapEasingToNativeEasing=y,e.maxGeneratorDuration=2e4,e.microtask=x,e.motionValue=function(e,t){return new Q(e,t)},e.press=function(e,t,n={}){const[i,a,s]=j(e,n),o=e=>{const i=e.currentTarget;if(!$(e)||G.has(i))return;G.add(i);const s=t(i,e),o=(e,t)=>{window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",c),$(e)&&G.has(i)&&(G.delete(i),"function"==typeof s&&s(e,{success:t}))},r=e=>{o(e,i===window||i===document||n.useGlobalTarget||D(i,e.target))},c=e=>{o(e,!1)};window.addEventListener("pointerup",r,a),window.addEventListener("pointercancel",c,a)};return i.forEach(e=>{var t;(n.useGlobalTarget?window:e).addEventListener("pointerdown",o,a),e instanceof HTMLElement&&(e.addEventListener("focus",e=>((e,t)=>{const n=e.currentTarget;if(!n)return;const i=B(()=>{if(G.has(n))return;I(n,"down");const e=B(()=>{I(n,"up")});n.addEventListener("keyup",e,t),n.addEventListener("blur",()=>I(n,"cancel"),t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)})(e,a)),t=e,O.has(t.tagName)||-1!==t.tabIndex||null!==e.tabIndex||(e.tabIndex=0))}),s},e.recordStats=function(){if(w.value)throw H(),new Error("Stats are already being measured");const e=w;return e.value={frameloop:{rate:[],read:[],resolveKeyframes:[],update:[],preRender:[],render:[],postRender:[]},animations:{mainThread:[],waapi:[],layout:[]},layoutProjection:{nodes:[],calculatedTargetDeltas:[],calculatedProjections:[]}},e.addProjectionMetrics=t=>{const{layoutProjection:n}=e.value;n.nodes.push(t.nodes),n.calculatedTargetDeltas.push(t.calculatedTargetDeltas),n.calculatedProjections.push(t.calculatedProjections)},E.postRender(K,!0),X},e.resolveElements=R,e.setDragLock=function(e){return"x"===e||"y"===e?V[e]?null:(V[e]=!0,()=>{V[e]=!1}):V.x||V.y?null:(V.x=V.y=!0,()=>{V.x=V.y=!1})},e.statsBuffer=w,e.supportedWaapiEasing=v,e.supportsFlags=d,e.supportsLinearEasing=m,e.supportsScrollTimeline=n,e.time=L}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-dom",
3
- "version": "12.6.0",
3
+ "version": "12.6.3-alpha.0",
4
4
  "author": "Matt Perry",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/motiondivision/motion",
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "motion-utils": "^12.5.0"
19
+ "motion-utils": "^12.6.3-alpha.0"
20
20
  },
21
21
  "scripts": {
22
22
  "clean": "rm -rf types dist lib",
@@ -24,5 +24,5 @@
24
24
  "dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\"",
25
25
  "test": "jest --config jest.config.json --max-workers=2 motion-value.test"
26
26
  },
27
- "gitHead": "1c1f25b8fb696e07eb5807ba7ac5b03a832d0a00"
27
+ "gitHead": "ad91b03af6fb96f83c94e8d7b94dae3f379ba5d2"
28
28
  }
@@ -1,13 +0,0 @@
1
- function capturePointer(event, action) {
2
- const actionName = `${action}PointerCapture`;
3
- if (event.target instanceof Element &&
4
- actionName in event.target &&
5
- event.pointerId !== undefined) {
6
- try {
7
- event.target[actionName](event.pointerId);
8
- }
9
- catch (e) { }
10
- }
11
- }
12
-
13
- export { capturePointer };