motion 12.0.0-alpha.2 → 12.0.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/LICENSE.md +1 -1
- package/README.md +7 -24
- package/dist/cjs/index.js +2792 -2446
- package/dist/cjs/mini.js +629 -193
- package/dist/cjs/react-client.js +3624 -3434
- package/dist/cjs/react-m.js +397 -351
- package/dist/cjs/react-mini.js +225 -191
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +16 -12
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +10 -10
- package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +30 -89
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +4 -4
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/generators/spring/defaults.mjs +27 -0
- package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +10 -13
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +57 -18
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +7 -6
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +6 -5
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +32 -6
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +13 -0
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +10 -7
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +6 -3
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -1
- package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +6 -6
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +5 -4
- package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +2 -1
- package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +3 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +12 -15
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +20 -22
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +6 -5
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +20 -119
- package/dist/es/framer-motion/dist/es/motion/index.mjs +11 -7
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +3 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +11 -5
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -2
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +15 -14
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +15 -13
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +4 -4
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +6 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +2 -14
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +6 -20
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +2 -2
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/html/utils/keys-position.mjs +13 -0
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +6 -6
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +57 -24
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +8 -5
- package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +3 -3
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +1 -1
- package/dist/es/motion/lib/index.mjs +12 -7
- package/dist/es/motion/lib/mini.mjs +1 -0
- package/dist/es/motion/lib/react.mjs +41 -37
- package/dist/es/{framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom/dist/es/animation/controls/BaseGroup.mjs} +7 -6
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +13 -0
- package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es/animation/generators}/utils/create-generator-easing.mjs +6 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +85 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/linear.mjs +4 -4
- package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +9 -0
- package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +28 -0
- package/dist/es/motion-dom/dist/es/gestures/hover.mjs +37 -0
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +76 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +38 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/state.mjs +3 -0
- package/dist/es/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +22 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs → motion-dom/dist/es/utils/supports/memo.mjs} +3 -2
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/memo.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/noop.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/progress.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/time-conversion.mjs +2 -0
- package/dist/motion.dev.js +2792 -2446
- package/dist/motion.js +1 -1
- package/package.json +6 -6
- package/.turbo/turbo-build.log +0 -47
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +0 -53
- package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +0 -28
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/mini.js +0 -2
- package/lib/mini.js.map +0 -1
- package/lib/react-client.js +0 -3
- package/lib/react-client.js.map +0 -1
- package/lib/react-m.js +0 -3
- package/lib/react-m.js.map +0 -1
- package/lib/react-mini.js +0 -3
- package/lib/react-mini.js.map +0 -1
- package/lib/react.js +0 -3
- package/lib/react.js.map +0 -1
- package/rollup.config.mjs +0 -210
- package/src/index.ts +0 -1
- package/src/mini.ts +0 -1
- package/src/react-client.ts +0 -3
- package/src/react-m.ts +0 -3
- package/src/react-mini.ts +0 -3
- package/src/react.ts +0 -3
- package/tsconfig.json +0 -25
- package/types/index.d.ts +0 -1
- package/types/mini.d.ts +0 -1
- package/types/react-client.d.ts +0 -1
- package/types/react-m.d.ts +0 -1
- package/types/react-mini.d.ts +0 -1
- package/types/react.d.ts +0 -1
- /package/dist/es/framer-motion/dist/es/render/html/utils/{transform.mjs → keys-transform.mjs} +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/gestures/utils/is-node-or-child.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/events → motion-dom/dist/es/gestures}/utils/is-primary-pointer.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/errors.mjs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { acceleratedValues } from '../../animation/animators/utils/accelerated-values.mjs';
|
|
2
2
|
import { camelToDash } from '../../render/dom/utils/camel-to-dash.mjs';
|
|
3
|
-
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
3
|
+
import { transformProps } from '../../render/html/utils/keys-transform.mjs';
|
|
4
4
|
|
|
5
5
|
function getWillChangeName(name) {
|
|
6
6
|
if (transformProps.has(name)) {
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { hover } from '../../motion-dom/dist/es/gestures/hover.mjs';
|
|
2
|
+
export { isDragActive } from '../../motion-dom/dist/es/gestures/drag/state/is-active.mjs';
|
|
3
|
+
export { press } from '../../motion-dom/dist/es/gestures/press/index.mjs';
|
|
4
|
+
export { invariant } from '../../motion-utils/dist/es/errors.mjs';
|
|
5
|
+
export { noop } from '../../motion-utils/dist/es/noop.mjs';
|
|
6
|
+
export { progress } from '../../motion-utils/dist/es/progress.mjs';
|
|
2
7
|
export { animate, createScopedAnimate } from '../../framer-motion/dist/es/animation/animate/index.mjs';
|
|
3
8
|
export { animateMini } from '../../framer-motion/dist/es/animation/animators/waapi/animate-style.mjs';
|
|
4
9
|
export { scroll } from '../../framer-motion/dist/es/render/dom/scroll/index.mjs';
|
|
5
10
|
export { scrollInfo } from '../../framer-motion/dist/es/render/dom/scroll/track.mjs';
|
|
6
11
|
export { inView } from '../../framer-motion/dist/es/render/dom/viewport/index.mjs';
|
|
12
|
+
export { MotionValue, motionValue } from '../../framer-motion/dist/es/value/index.mjs';
|
|
7
13
|
export { anticipate } from '../../framer-motion/dist/es/easing/anticipate.mjs';
|
|
8
14
|
export { backIn, backInOut, backOut } from '../../framer-motion/dist/es/easing/back.mjs';
|
|
9
15
|
export { circIn, circInOut, circOut } from '../../framer-motion/dist/es/easing/circ.mjs';
|
|
10
|
-
export { easeIn, easeInOut, easeOut } from '../../framer-motion/dist/es/easing/ease.mjs';
|
|
11
16
|
export { cubicBezier } from '../../framer-motion/dist/es/easing/cubic-bezier.mjs';
|
|
12
|
-
export {
|
|
17
|
+
export { easeIn, easeInOut, easeOut } from '../../framer-motion/dist/es/easing/ease.mjs';
|
|
13
18
|
export { mirrorEasing } from '../../framer-motion/dist/es/easing/modifiers/mirror.mjs';
|
|
14
19
|
export { reverseEasing } from '../../framer-motion/dist/es/easing/modifiers/reverse.mjs';
|
|
15
|
-
export {
|
|
20
|
+
export { steps } from '../../framer-motion/dist/es/easing/steps.mjs';
|
|
16
21
|
export { inertia } from '../../framer-motion/dist/es/animation/generators/inertia.mjs';
|
|
17
22
|
export { keyframes } from '../../framer-motion/dist/es/animation/generators/keyframes.mjs';
|
|
23
|
+
export { spring } from '../../framer-motion/dist/es/animation/generators/spring/index.mjs';
|
|
18
24
|
export { stagger } from '../../framer-motion/dist/es/animation/utils/stagger.mjs';
|
|
19
|
-
export {
|
|
25
|
+
export { time } from '../../framer-motion/dist/es/frameloop/sync-time.mjs';
|
|
20
26
|
export { clamp } from '../../framer-motion/dist/es/utils/clamp.mjs';
|
|
21
27
|
export { delayInSeconds as delay } from '../../framer-motion/dist/es/utils/delay.mjs';
|
|
22
28
|
export { distance, distance2D } from '../../framer-motion/dist/es/utils/distance.mjs';
|
|
23
|
-
export { invariant, warning } from '../../framer-motion/dist/es/utils/errors.mjs';
|
|
24
29
|
export { interpolate } from '../../framer-motion/dist/es/utils/interpolate.mjs';
|
|
25
30
|
export { mix } from '../../framer-motion/dist/es/utils/mix/index.mjs';
|
|
26
31
|
export { pipe } from '../../framer-motion/dist/es/utils/pipe.mjs';
|
|
27
|
-
export {
|
|
32
|
+
export { transform } from '../../framer-motion/dist/es/utils/transform.mjs';
|
|
28
33
|
export { wrap } from '../../framer-motion/dist/es/utils/wrap.mjs';
|
|
29
34
|
export { cancelSync, sync } from '../../framer-motion/dist/es/frameloop/index-legacy.mjs';
|
|
30
35
|
export { cancelFrame, frame, frameData, frameSteps } from '../../framer-motion/dist/es/frameloop/frame.mjs';
|
|
@@ -1,104 +1,108 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { motion } from '../../framer-motion/dist/es/render/components/motion/proxy.mjs';
|
|
3
|
-
export { m } from '../../framer-motion/dist/es/render/components/m/proxy.mjs';
|
|
4
2
|
export { AnimatePresence } from '../../framer-motion/dist/es/components/AnimatePresence/index.mjs';
|
|
5
|
-
export { MotionConfig } from '../../framer-motion/dist/es/components/MotionConfig/index.mjs';
|
|
6
|
-
export { LazyMotion } from '../../framer-motion/dist/es/components/LazyMotion/index.mjs';
|
|
7
3
|
export { LayoutGroup } from '../../framer-motion/dist/es/components/LayoutGroup/index.mjs';
|
|
8
|
-
export {
|
|
4
|
+
export { LazyMotion } from '../../framer-motion/dist/es/components/LazyMotion/index.mjs';
|
|
5
|
+
export { MotionConfig } from '../../framer-motion/dist/es/components/MotionConfig/index.mjs';
|
|
6
|
+
export { m } from '../../framer-motion/dist/es/render/components/m/proxy.mjs';
|
|
7
|
+
export { motion } from '../../framer-motion/dist/es/render/components/motion/proxy.mjs';
|
|
9
8
|
export { domAnimation } from '../../framer-motion/dist/es/render/dom/features-animation.mjs';
|
|
10
9
|
export { domMax } from '../../framer-motion/dist/es/render/dom/features-max.mjs';
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { resolveMotionValue } from '../../framer-motion/dist/es/value/utils/resolve-motion-value.mjs';
|
|
14
|
-
export { useTransform } from '../../framer-motion/dist/es/value/use-transform.mjs';
|
|
15
|
-
export { useSpring } from '../../framer-motion/dist/es/value/use-spring.mjs';
|
|
16
|
-
export { useVelocity } from '../../framer-motion/dist/es/value/use-velocity.mjs';
|
|
17
|
-
export { useScroll } from '../../framer-motion/dist/es/value/use-scroll.mjs';
|
|
10
|
+
export { domMin } from '../../framer-motion/dist/es/render/dom/features-min.mjs';
|
|
11
|
+
export { useMotionValueEvent } from '../../framer-motion/dist/es/utils/use-motion-value-event.mjs';
|
|
18
12
|
export { useElementScroll } from '../../framer-motion/dist/es/value/scroll/use-element-scroll.mjs';
|
|
19
13
|
export { useViewportScroll } from '../../framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs';
|
|
14
|
+
export { useMotionTemplate } from '../../framer-motion/dist/es/value/use-motion-template.mjs';
|
|
15
|
+
export { useMotionValue } from '../../framer-motion/dist/es/value/use-motion-value.mjs';
|
|
16
|
+
export { useScroll } from '../../framer-motion/dist/es/value/use-scroll.mjs';
|
|
17
|
+
export { useSpring } from '../../framer-motion/dist/es/value/use-spring.mjs';
|
|
20
18
|
export { useTime } from '../../framer-motion/dist/es/value/use-time.mjs';
|
|
19
|
+
export { useTransform } from '../../framer-motion/dist/es/value/use-transform.mjs';
|
|
20
|
+
export { useVelocity } from '../../framer-motion/dist/es/value/use-velocity.mjs';
|
|
21
21
|
export { useWillChange } from '../../framer-motion/dist/es/value/use-will-change/index.mjs';
|
|
22
|
-
export {
|
|
22
|
+
export { resolveMotionValue } from '../../framer-motion/dist/es/value/utils/resolve-motion-value.mjs';
|
|
23
23
|
export { useReducedMotion } from '../../framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs';
|
|
24
24
|
export { useReducedMotionConfig } from '../../framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs';
|
|
25
|
+
export { AcceleratedAnimation } from '../../framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs';
|
|
26
|
+
export { animateValue } from '../../framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs';
|
|
25
27
|
export { animationControls } from '../../framer-motion/dist/es/animation/hooks/animation-controls.mjs';
|
|
26
28
|
export { useAnimate } from '../../framer-motion/dist/es/animation/hooks/use-animate.mjs';
|
|
27
29
|
export { useAnimateMini } from '../../framer-motion/dist/es/animation/hooks/use-animate-style.mjs';
|
|
28
30
|
export { useAnimation, useAnimationControls } from '../../framer-motion/dist/es/animation/hooks/use-animation.mjs';
|
|
29
|
-
export { useAnimationFrame } from '../../framer-motion/dist/es/utils/use-animation-frame.mjs';
|
|
30
31
|
export { animateVisualElement } from '../../framer-motion/dist/es/animation/interfaces/visual-element.mjs';
|
|
31
|
-
export { useCycle } from '../../framer-motion/dist/es/utils/use-cycle.mjs';
|
|
32
|
-
export { isValidMotionProp } from '../../framer-motion/dist/es/motion/utils/valid-prop.mjs';
|
|
33
32
|
export { useIsPresent, usePresence } from '../../framer-motion/dist/es/components/AnimatePresence/use-presence.mjs';
|
|
34
|
-
export { useInView } from '../../framer-motion/dist/es/utils/use-in-view.mjs';
|
|
35
|
-
export { DragControls, useDragControls } from '../../framer-motion/dist/es/gestures/drag/use-drag-controls.mjs';
|
|
36
33
|
export { useDomEvent } from '../../framer-motion/dist/es/events/use-dom-event.mjs';
|
|
34
|
+
export { DragControls, useDragControls } from '../../framer-motion/dist/es/gestures/drag/use-drag-controls.mjs';
|
|
37
35
|
export { createRendererMotionComponent } from '../../framer-motion/dist/es/motion/index.mjs';
|
|
38
36
|
export { isMotionComponent } from '../../framer-motion/dist/es/motion/utils/is-motion-component.mjs';
|
|
39
37
|
export { unwrapMotionComponent } from '../../framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs';
|
|
40
|
-
export {
|
|
38
|
+
export { isValidMotionProp } from '../../framer-motion/dist/es/motion/utils/valid-prop.mjs';
|
|
41
39
|
export { addScaleCorrector } from '../../framer-motion/dist/es/projection/styles/scale-correction.mjs';
|
|
42
|
-
export { disableInstantTransitions, useInstantTransition } from '../../framer-motion/dist/es/utils/use-instant-transition.mjs';
|
|
43
40
|
export { useInstantLayoutTransition } from '../../framer-motion/dist/es/projection/use-instant-layout-transition.mjs';
|
|
44
41
|
export { useResetProjection } from '../../framer-motion/dist/es/projection/use-reset-projection.mjs';
|
|
45
42
|
export { buildTransform } from '../../framer-motion/dist/es/render/html/utils/build-transform.mjs';
|
|
46
43
|
export { visualElementStore } from '../../framer-motion/dist/es/render/store.mjs';
|
|
47
|
-
export {
|
|
44
|
+
export { VisualElement } from '../../framer-motion/dist/es/render/VisualElement.mjs';
|
|
45
|
+
export { MotionGlobalConfig } from '../../framer-motion/dist/es/utils/GlobalConfig.mjs';
|
|
46
|
+
export { useAnimationFrame } from '../../framer-motion/dist/es/utils/use-animation-frame.mjs';
|
|
47
|
+
export { useCycle } from '../../framer-motion/dist/es/utils/use-cycle.mjs';
|
|
48
|
+
export { useInView } from '../../framer-motion/dist/es/utils/use-in-view.mjs';
|
|
49
|
+
export { disableInstantTransitions, useInstantTransition } from '../../framer-motion/dist/es/utils/use-instant-transition.mjs';
|
|
48
50
|
export { color } from '../../framer-motion/dist/es/value/types/color/index.mjs';
|
|
49
51
|
export { complex } from '../../framer-motion/dist/es/value/types/complex/index.mjs';
|
|
50
52
|
export { px } from '../../framer-motion/dist/es/value/types/numbers/units.mjs';
|
|
51
|
-
export { MotionGlobalConfig } from '../../framer-motion/dist/es/utils/GlobalConfig.mjs';
|
|
52
|
-
export { AcceleratedAnimation } from '../../framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs';
|
|
53
|
-
export { startOptimizedAppearAnimation } from '../../framer-motion/dist/es/animation/optimized-appear/start.mjs';
|
|
54
|
-
export { optimizedAppearDataAttribute } from '../../framer-motion/dist/es/animation/optimized-appear/data-id.mjs';
|
|
55
53
|
export { spring } from '../../framer-motion/dist/es/animation/generators/spring/index.mjs';
|
|
56
54
|
export { findSpring } from '../../framer-motion/dist/es/animation/generators/spring/find.mjs';
|
|
57
|
-
export {
|
|
55
|
+
export { optimizedAppearDataAttribute } from '../../framer-motion/dist/es/animation/optimized-appear/data-id.mjs';
|
|
56
|
+
export { startOptimizedAppearAnimation } from '../../framer-motion/dist/es/animation/optimized-appear/start.mjs';
|
|
57
|
+
export { LayoutGroupContext } from '../../framer-motion/dist/es/context/LayoutGroupContext.mjs';
|
|
58
58
|
export { MotionConfigContext } from '../../framer-motion/dist/es/context/MotionConfigContext.mjs';
|
|
59
|
+
export { MotionContext } from '../../framer-motion/dist/es/context/MotionContext/index.mjs';
|
|
59
60
|
export { PresenceContext } from '../../framer-motion/dist/es/context/PresenceContext.mjs';
|
|
60
|
-
export { LayoutGroupContext } from '../../framer-motion/dist/es/context/LayoutGroupContext.mjs';
|
|
61
61
|
export { SwitchLayoutGroupContext } from '../../framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs';
|
|
62
62
|
export { FlatTree } from '../../framer-motion/dist/es/render/utils/flat-tree.mjs';
|
|
63
|
-
export { DeprecatedLayoutGroupContext } from '../../framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs';
|
|
64
63
|
export { useAnimatedState as useDeprecatedAnimatedState } from '../../framer-motion/dist/es/animation/hooks/use-animated-state.mjs';
|
|
65
|
-
export { useInvertedScale as useDeprecatedInvertedScale } from '../../framer-motion/dist/es/value/use-inverted-scale.mjs';
|
|
66
64
|
export { AnimateSharedLayout } from '../../framer-motion/dist/es/components/AnimateSharedLayout.mjs';
|
|
65
|
+
export { DeprecatedLayoutGroupContext } from '../../framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs';
|
|
66
|
+
export { useInvertedScale as useDeprecatedInvertedScale } from '../../framer-motion/dist/es/value/use-inverted-scale.mjs';
|
|
67
67
|
export { delay } from '../../framer-motion/dist/es/utils/delay.mjs';
|
|
68
|
-
export {
|
|
68
|
+
export { hover } from '../../motion-dom/dist/es/gestures/hover.mjs';
|
|
69
|
+
export { isDragActive } from '../../motion-dom/dist/es/gestures/drag/state/is-active.mjs';
|
|
70
|
+
export { press } from '../../motion-dom/dist/es/gestures/press/index.mjs';
|
|
71
|
+
export { invariant } from '../../motion-utils/dist/es/errors.mjs';
|
|
72
|
+
export { noop } from '../../motion-utils/dist/es/noop.mjs';
|
|
73
|
+
export { progress } from '../../motion-utils/dist/es/progress.mjs';
|
|
69
74
|
export { animate, createScopedAnimate } from '../../framer-motion/dist/es/animation/animate/index.mjs';
|
|
70
75
|
export { animateMini } from '../../framer-motion/dist/es/animation/animators/waapi/animate-style.mjs';
|
|
71
76
|
export { scroll } from '../../framer-motion/dist/es/render/dom/scroll/index.mjs';
|
|
72
77
|
export { scrollInfo } from '../../framer-motion/dist/es/render/dom/scroll/track.mjs';
|
|
73
78
|
export { inView } from '../../framer-motion/dist/es/render/dom/viewport/index.mjs';
|
|
79
|
+
export { MotionValue, motionValue } from '../../framer-motion/dist/es/value/index.mjs';
|
|
74
80
|
export { inertia } from '../../framer-motion/dist/es/animation/generators/inertia.mjs';
|
|
75
81
|
export { keyframes } from '../../framer-motion/dist/es/animation/generators/keyframes.mjs';
|
|
76
82
|
export { stagger } from '../../framer-motion/dist/es/animation/utils/stagger.mjs';
|
|
77
|
-
export {
|
|
83
|
+
export { time } from '../../framer-motion/dist/es/frameloop/sync-time.mjs';
|
|
78
84
|
export { clamp } from '../../framer-motion/dist/es/utils/clamp.mjs';
|
|
79
85
|
export { mix } from '../../framer-motion/dist/es/utils/mix/index.mjs';
|
|
80
86
|
export { pipe } from '../../framer-motion/dist/es/utils/pipe.mjs';
|
|
81
|
-
export {
|
|
87
|
+
export { transform } from '../../framer-motion/dist/es/utils/transform.mjs';
|
|
82
88
|
export { wrap } from '../../framer-motion/dist/es/utils/wrap.mjs';
|
|
83
89
|
export { cancelSync, sync } from '../../framer-motion/dist/es/frameloop/index-legacy.mjs';
|
|
84
90
|
export { anticipate } from '../../framer-motion/dist/es/easing/anticipate.mjs';
|
|
85
91
|
export { backIn, backInOut, backOut } from '../../framer-motion/dist/es/easing/back.mjs';
|
|
86
92
|
export { circIn, circInOut, circOut } from '../../framer-motion/dist/es/easing/circ.mjs';
|
|
87
|
-
export { easeIn, easeInOut, easeOut } from '../../framer-motion/dist/es/easing/ease.mjs';
|
|
88
93
|
export { cubicBezier } from '../../framer-motion/dist/es/easing/cubic-bezier.mjs';
|
|
89
|
-
export {
|
|
94
|
+
export { easeIn, easeInOut, easeOut } from '../../framer-motion/dist/es/easing/ease.mjs';
|
|
90
95
|
export { mirrorEasing } from '../../framer-motion/dist/es/easing/modifiers/mirror.mjs';
|
|
91
96
|
export { reverseEasing } from '../../framer-motion/dist/es/easing/modifiers/reverse.mjs';
|
|
97
|
+
export { steps } from '../../framer-motion/dist/es/easing/steps.mjs';
|
|
98
|
+
export { cancelFrame, frame, frameData, frameSteps } from '../../framer-motion/dist/es/frameloop/frame.mjs';
|
|
92
99
|
export { distance, distance2D } from '../../framer-motion/dist/es/utils/distance.mjs';
|
|
93
|
-
export { invariant, warning } from '../../framer-motion/dist/es/utils/errors.mjs';
|
|
94
100
|
export { interpolate } from '../../framer-motion/dist/es/utils/interpolate.mjs';
|
|
95
|
-
export { cancelFrame, frame, frameData, frameSteps } from '../../framer-motion/dist/es/frameloop/frame.mjs';
|
|
96
101
|
export { animations } from '../../framer-motion/dist/es/motion/features/animations.mjs';
|
|
97
102
|
export { createBox } from '../../framer-motion/dist/es/projection/geometry/models.mjs';
|
|
98
103
|
export { calcLength } from '../../framer-motion/dist/es/projection/geometry/delta-calc.mjs';
|
|
99
104
|
export { filterProps } from '../../framer-motion/dist/es/render/dom/utils/filter-props.mjs';
|
|
100
105
|
export { makeUseVisualState } from '../../framer-motion/dist/es/motion/utils/use-visual-state.mjs';
|
|
101
|
-
export { isDragActive } from '../../framer-motion/dist/es/gestures/drag/utils/lock.mjs';
|
|
102
106
|
export { addPointerEvent } from '../../framer-motion/dist/es/events/add-pointer-event.mjs';
|
|
103
107
|
export { addPointerInfo } from '../../framer-motion/dist/es/events/event-info.mjs';
|
|
104
108
|
export { isMotionValue } from '../../framer-motion/dist/es/value/utils/is-motion-value.mjs';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { supportsScrollTimeline } from '
|
|
1
|
+
import { supportsScrollTimeline } from '../../utils/supports/scroll-timeline.mjs';
|
|
2
2
|
|
|
3
|
-
class
|
|
3
|
+
class BaseGroupPlaybackControls {
|
|
4
4
|
constructor(animations) {
|
|
5
5
|
// Bound to accomodate common `return animation.stop` pattern
|
|
6
6
|
this.stop = () => this.runAll("stop");
|
|
7
7
|
this.animations = animations.filter(Boolean);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
get finished() {
|
|
10
|
+
// Support for new finished Promise and legacy thennable API
|
|
11
|
+
return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* TODO: Filter out cancelled or stopped animations before returning
|
|
@@ -25,7 +26,7 @@ class GroupPlaybackControls {
|
|
|
25
26
|
if (supportsScrollTimeline() && animation.attachTimeline) {
|
|
26
27
|
return animation.attachTimeline(timeline);
|
|
27
28
|
}
|
|
28
|
-
else {
|
|
29
|
+
else if (typeof fallback === "function") {
|
|
29
30
|
return fallback(animation);
|
|
30
31
|
}
|
|
31
32
|
});
|
|
@@ -78,4 +79,4 @@ class GroupPlaybackControls {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
export {
|
|
82
|
+
export { BaseGroupPlaybackControls };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseGroupPlaybackControls } from './BaseGroup.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TODO: This is a temporary class to support the legacy
|
|
5
|
+
* thennable API
|
|
6
|
+
*/
|
|
7
|
+
class GroupPlaybackControls extends BaseGroupPlaybackControls {
|
|
8
|
+
then(onResolve, onReject) {
|
|
9
|
+
return Promise.all(this.animations).then(onResolve).catch(onReject);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { GroupPlaybackControls };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { millisecondsToSeconds } from '
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { millisecondsToSeconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { calcGeneratorDuration, maxGeneratorDuration } from './calc-duration.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Create a progress => progress easing function from a generator.
|
|
@@ -9,7 +10,9 @@ function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
|
9
10
|
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
10
11
|
return {
|
|
11
12
|
type: "keyframes",
|
|
12
|
-
ease: (progress) =>
|
|
13
|
+
ease: (progress) => {
|
|
14
|
+
return generator.next(duration * progress).value / scale;
|
|
15
|
+
},
|
|
13
16
|
duration: millisecondsToSeconds(duration),
|
|
14
17
|
};
|
|
15
18
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { attachTimeline } from './utils/attach-timeline.mjs';
|
|
5
|
+
|
|
6
|
+
class NativeAnimationControls {
|
|
7
|
+
constructor(animation) {
|
|
8
|
+
this.animation = animation;
|
|
9
|
+
}
|
|
10
|
+
get duration() {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) ||
|
|
13
|
+
((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) ||
|
|
14
|
+
300;
|
|
15
|
+
return millisecondsToSeconds(Number(durationInMs));
|
|
16
|
+
}
|
|
17
|
+
get time() {
|
|
18
|
+
var _a;
|
|
19
|
+
if (this.animation) {
|
|
20
|
+
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
set time(newTime) {
|
|
25
|
+
if (this.animation) {
|
|
26
|
+
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
get speed() {
|
|
30
|
+
return this.animation ? this.animation.playbackRate : 1;
|
|
31
|
+
}
|
|
32
|
+
set speed(newSpeed) {
|
|
33
|
+
if (this.animation) {
|
|
34
|
+
this.animation.playbackRate = newSpeed;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
get state() {
|
|
38
|
+
return this.animation ? this.animation.playState : "finished";
|
|
39
|
+
}
|
|
40
|
+
get startTime() {
|
|
41
|
+
return this.animation ? this.animation.startTime : null;
|
|
42
|
+
}
|
|
43
|
+
get finished() {
|
|
44
|
+
return this.animation ? this.animation.finished : Promise.resolve();
|
|
45
|
+
}
|
|
46
|
+
play() {
|
|
47
|
+
this.animation && this.animation.play();
|
|
48
|
+
}
|
|
49
|
+
pause() {
|
|
50
|
+
this.animation && this.animation.pause();
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
if (!this.animation ||
|
|
54
|
+
this.state === "idle" ||
|
|
55
|
+
this.state === "finished") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (this.animation.commitStyles) {
|
|
59
|
+
this.animation.commitStyles();
|
|
60
|
+
}
|
|
61
|
+
this.cancel();
|
|
62
|
+
}
|
|
63
|
+
flatten() {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!this.animation)
|
|
66
|
+
return;
|
|
67
|
+
(_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
|
|
68
|
+
}
|
|
69
|
+
attachTimeline(timeline) {
|
|
70
|
+
if (this.animation)
|
|
71
|
+
attachTimeline(this.animation, timeline);
|
|
72
|
+
return noop;
|
|
73
|
+
}
|
|
74
|
+
complete() {
|
|
75
|
+
this.animation && this.animation.finish();
|
|
76
|
+
}
|
|
77
|
+
cancel() {
|
|
78
|
+
try {
|
|
79
|
+
this.animation && this.animation.cancel();
|
|
80
|
+
}
|
|
81
|
+
catch (e) { }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { NativeAnimationControls };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isBezierDefinition } from '../../../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isBezierDefinition } from '../../../utils/is-bezier-definition.mjs';
|
|
2
|
+
import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
|
|
3
|
+
import { generateLinearEasing } from './linear.mjs';
|
|
4
4
|
|
|
5
5
|
function isWaapiSupportedEasing(easing) {
|
|
6
6
|
return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const generateLinearEasing = (easing, duration // as milliseconds
|
|
4
|
+
const generateLinearEasing = (easing, duration, // as milliseconds
|
|
5
|
+
resolution = 10 // as milliseconds
|
|
6
6
|
) => {
|
|
7
7
|
let points = "";
|
|
8
8
|
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isDragging } from './is-active.mjs';
|
|
2
|
+
|
|
3
|
+
function setDragLock(axis) {
|
|
4
|
+
if (axis === "x" || axis === "y") {
|
|
5
|
+
if (isDragging[axis]) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
isDragging[axis] = true;
|
|
10
|
+
return () => {
|
|
11
|
+
isDragging[axis] = false;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (isDragging.x || isDragging.y) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
isDragging.x = isDragging.y = true;
|
|
21
|
+
return () => {
|
|
22
|
+
isDragging.x = isDragging.y = false;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { setDragLock };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isDragActive } from './drag/state/is-active.mjs';
|
|
2
|
+
import { setupGesture } from './utils/setup.mjs';
|
|
3
|
+
|
|
4
|
+
function isValidHover(event) {
|
|
5
|
+
return !(event.pointerType === "touch" || isDragActive());
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a hover gesture. hover() is different to .addEventListener("pointerenter")
|
|
9
|
+
* in that it has an easier syntax, filters out polyfilled touch events, interoperates
|
|
10
|
+
* with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
15
|
+
const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
|
|
16
|
+
const onPointerEnter = (enterEvent) => {
|
|
17
|
+
if (!isValidHover(enterEvent))
|
|
18
|
+
return;
|
|
19
|
+
const { target } = enterEvent;
|
|
20
|
+
const onHoverEnd = onHoverStart(target, enterEvent);
|
|
21
|
+
if (typeof onHoverEnd !== "function" || !target)
|
|
22
|
+
return;
|
|
23
|
+
const onPointerLeave = (leaveEvent) => {
|
|
24
|
+
if (!isValidHover(leaveEvent))
|
|
25
|
+
return;
|
|
26
|
+
onHoverEnd(leaveEvent);
|
|
27
|
+
target.removeEventListener("pointerleave", onPointerLeave);
|
|
28
|
+
};
|
|
29
|
+
target.addEventListener("pointerleave", onPointerLeave, eventOptions);
|
|
30
|
+
};
|
|
31
|
+
elements.forEach((element) => {
|
|
32
|
+
element.addEventListener("pointerenter", onPointerEnter, eventOptions);
|
|
33
|
+
});
|
|
34
|
+
return cancel;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { hover };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isDragActive } from '../drag/state/is-active.mjs';
|
|
2
|
+
import { isNodeOrChild } from '../utils/is-node-or-child.mjs';
|
|
3
|
+
import { isPrimaryPointer } from '../utils/is-primary-pointer.mjs';
|
|
4
|
+
import { setupGesture } from '../utils/setup.mjs';
|
|
5
|
+
import { isElementKeyboardAccessible } from './utils/is-keyboard-accessible.mjs';
|
|
6
|
+
import { enableKeyboardPress } from './utils/keyboard.mjs';
|
|
7
|
+
import { isPressing } from './utils/state.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Filter out events that are not primary pointer events, or are triggering
|
|
11
|
+
* while a Motion gesture is active.
|
|
12
|
+
*/
|
|
13
|
+
function isValidPressEvent(event) {
|
|
14
|
+
return isPrimaryPointer(event) && !isDragActive();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a press gesture.
|
|
18
|
+
*
|
|
19
|
+
* Press is different to `"pointerdown"`, `"pointerup"` in that it
|
|
20
|
+
* automatically filters out secondary pointer events like right
|
|
21
|
+
* click and multitouch.
|
|
22
|
+
*
|
|
23
|
+
* It also adds accessibility support for keyboards, where
|
|
24
|
+
* an element with a press gesture will receive focus and
|
|
25
|
+
* trigger on Enter `"keydown"` and `"keyup"` events.
|
|
26
|
+
*
|
|
27
|
+
* This is different to a browser's `"click"` event, which does
|
|
28
|
+
* respond to keyboards but only for the `"click"` itself, rather
|
|
29
|
+
* than the press start and end/cancel. The element also needs
|
|
30
|
+
* to be focusable for this to work, whereas a press gesture will
|
|
31
|
+
* make an element focusable by default.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
function press(elementOrSelector, onPressStart, options = {}) {
|
|
36
|
+
const [elements, eventOptions, cancelEvents] = setupGesture(elementOrSelector, options);
|
|
37
|
+
const startPress = (startEvent) => {
|
|
38
|
+
const element = startEvent.currentTarget;
|
|
39
|
+
if (!isValidPressEvent(startEvent) || isPressing.has(element))
|
|
40
|
+
return;
|
|
41
|
+
isPressing.add(element);
|
|
42
|
+
const onPressEnd = onPressStart(element, startEvent);
|
|
43
|
+
const onPointerEnd = (endEvent, success) => {
|
|
44
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
45
|
+
window.removeEventListener("pointercancel", onPointerCancel);
|
|
46
|
+
if (!isValidPressEvent(endEvent) || !isPressing.has(element)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
isPressing.delete(element);
|
|
50
|
+
if (typeof onPressEnd === "function") {
|
|
51
|
+
onPressEnd(endEvent, { success });
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const onPointerUp = (upEvent) => {
|
|
55
|
+
onPointerEnd(upEvent, options.useGlobalTarget ||
|
|
56
|
+
isNodeOrChild(element, upEvent.target));
|
|
57
|
+
};
|
|
58
|
+
const onPointerCancel = (cancelEvent) => {
|
|
59
|
+
onPointerEnd(cancelEvent, false);
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("pointerup", onPointerUp, eventOptions);
|
|
62
|
+
window.addEventListener("pointercancel", onPointerCancel, eventOptions);
|
|
63
|
+
};
|
|
64
|
+
elements.forEach((element) => {
|
|
65
|
+
if (!isElementKeyboardAccessible(element) &&
|
|
66
|
+
element.getAttribute("tabindex") === null) {
|
|
67
|
+
element.tabIndex = 0;
|
|
68
|
+
}
|
|
69
|
+
const target = options.useGlobalTarget ? window : element;
|
|
70
|
+
target.addEventListener("pointerdown", startPress, eventOptions);
|
|
71
|
+
element.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
|
|
72
|
+
});
|
|
73
|
+
return cancelEvents;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { press };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const focusableElements = new Set([
|
|
2
|
+
"BUTTON",
|
|
3
|
+
"INPUT",
|
|
4
|
+
"SELECT",
|
|
5
|
+
"TEXTAREA",
|
|
6
|
+
"A",
|
|
7
|
+
]);
|
|
8
|
+
function isElementKeyboardAccessible(element) {
|
|
9
|
+
return (focusableElements.has(element.tagName) ||
|
|
10
|
+
element.tabIndex !== -1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { isElementKeyboardAccessible };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isPressing } from './state.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Filter out events that are not "Enter" keys.
|
|
5
|
+
*/
|
|
6
|
+
function filterEvents(callback) {
|
|
7
|
+
return (event) => {
|
|
8
|
+
if (event.key !== "Enter")
|
|
9
|
+
return;
|
|
10
|
+
callback(event);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function firePointerEvent(target, type) {
|
|
14
|
+
target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
|
|
15
|
+
}
|
|
16
|
+
const enableKeyboardPress = (focusEvent, eventOptions) => {
|
|
17
|
+
const element = focusEvent.currentTarget;
|
|
18
|
+
if (!element)
|
|
19
|
+
return;
|
|
20
|
+
const handleKeydown = filterEvents(() => {
|
|
21
|
+
if (isPressing.has(element))
|
|
22
|
+
return;
|
|
23
|
+
firePointerEvent(element, "down");
|
|
24
|
+
const handleKeyup = filterEvents(() => {
|
|
25
|
+
firePointerEvent(element, "up");
|
|
26
|
+
});
|
|
27
|
+
const handleBlur = () => firePointerEvent(element, "cancel");
|
|
28
|
+
element.addEventListener("keyup", handleKeyup, eventOptions);
|
|
29
|
+
element.addEventListener("blur", handleBlur, eventOptions);
|
|
30
|
+
});
|
|
31
|
+
element.addEventListener("keydown", handleKeydown, eventOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Add an event listener that fires on blur to remove the keydown events.
|
|
34
|
+
*/
|
|
35
|
+
element.addEventListener("blur", () => element.removeEventListener("keydown", handleKeydown), eventOptions);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { enableKeyboardPress };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { resolveElements } from '../../utils/resolve-elements.mjs';
|
|
2
|
+
|
|
3
|
+
function setupGesture(elementOrSelector, options) {
|
|
4
|
+
const elements = resolveElements(elementOrSelector);
|
|
5
|
+
const gestureAbortController = new AbortController();
|
|
6
|
+
const eventOptions = {
|
|
7
|
+
passive: true,
|
|
8
|
+
...options,
|
|
9
|
+
signal: gestureAbortController.signal,
|
|
10
|
+
};
|
|
11
|
+
const cancel = () => gestureAbortController.abort();
|
|
12
|
+
return [elements, eventOptions, cancel];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { setupGesture };
|