@kitlangton/solid-motion 0.1.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 +48 -0
- package/README.md +54 -0
- package/dist/animation/animate/index.d.ts +23 -0
- package/dist/animation/animate/resolve-subjects.d.ts +3 -0
- package/dist/animation/animate/sequence.d.ts +3 -0
- package/dist/animation/animate/subject.d.ts +7 -0
- package/dist/animation/sequence/create.d.ts +6 -0
- package/dist/animation/sequence/types.d.ts +51 -0
- package/dist/animation/sequence/utils/calc-repeat-duration.d.ts +1 -0
- package/dist/animation/sequence/utils/calc-time.d.ts +2 -0
- package/dist/animation/sequence/utils/edit.d.ts +5 -0
- package/dist/animation/sequence/utils/normalize-times.d.ts +1 -0
- package/dist/animation/sequence/utils/sort.d.ts +2 -0
- package/dist/animation/utils/create-visual-element.d.ts +2 -0
- package/dist/animation/utils/is-dom-keyframes.d.ts +2 -0
- package/dist/components/AnimatePresence.d.ts +27 -0
- package/dist/components/AnimatePresenceContext.d.ts +23 -0
- package/dist/components/AnimatePresenceTypes.d.ts +57 -0
- package/dist/components/MotionConfig.d.ts +16 -0
- package/dist/context/MotionContext/create.d.ts +3 -0
- package/dist/context/MotionContext/utils.d.ts +3 -0
- package/dist/context/MotionContext.d.ts +7 -0
- package/dist/context/PresenceContext.d.ts +13 -0
- package/dist/events/add-pointer-event.d.ts +2 -0
- package/dist/events/event-info.d.ts +4 -0
- package/dist/gestures/drag/VisualElementDragControls.d.ts +86 -0
- package/dist/gestures/drag/index.d.ts +11 -0
- package/dist/gestures/drag/utils/constraints.d.ts +77 -0
- package/dist/gestures/focus.d.ts +8 -0
- package/dist/gestures/hover.d.ts +5 -0
- package/dist/gestures/pan/PanSession.d.ts +102 -0
- package/dist/gestures/pan/index.d.ts +15 -0
- package/dist/gestures/press.d.ts +5 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +2466 -0
- package/dist/index.js.map +1 -0
- package/dist/motion/features/animation/exit.d.ts +7 -0
- package/dist/motion/features/animation/index.d.ts +9 -0
- package/dist/motion/features/animations.d.ts +10 -0
- package/dist/motion/features/definitions.d.ts +3 -0
- package/dist/motion/features/feature-bundle.d.ts +34 -0
- package/dist/motion/features/gestures.d.ts +26 -0
- package/dist/motion/features/load-features.d.ts +1 -0
- package/dist/motion/index.d.ts +22 -0
- package/dist/motion/types.d.ts +27 -0
- package/dist/motion/utils/drag-projection.d.ts +3 -0
- package/dist/motion/utils/use-visual-state.d.ts +14 -0
- package/dist/motion/utils/valid-prop.d.ts +1 -0
- package/dist/render/dom/create-visual-element.d.ts +2 -0
- package/dist/render/dom/filter-props.d.ts +2 -0
- package/dist/render/dom/is-svg-component.d.ts +1 -0
- package/dist/render/dom/style.d.ts +1 -0
- package/dist/render/html/use-props.d.ts +7 -0
- package/dist/render/html/utils/create-render-state.d.ts +2 -0
- package/dist/render/svg/lowercase-elements.d.ts +1 -0
- package/dist/render/svg/use-props.d.ts +3 -0
- package/dist/render/svg/utils/create-render-state.d.ts +2 -0
- package/dist/render/types.d.ts +3 -0
- package/dist/server.js +2407 -0
- package/dist/server.js.map +1 -0
- package/dist/source/animation/animate/index.js +39 -0
- package/dist/source/animation/animate/resolve-subjects.js +19 -0
- package/dist/source/animation/animate/sequence.js +11 -0
- package/dist/source/animation/animate/subject.js +37 -0
- package/dist/source/animation/sequence/create.js +171 -0
- package/dist/source/animation/sequence/types.js +1 -0
- package/dist/source/animation/sequence/utils/calc-repeat-duration.js +3 -0
- package/dist/source/animation/sequence/utils/calc-time.js +17 -0
- package/dist/source/animation/sequence/utils/edit.js +21 -0
- package/dist/source/animation/sequence/utils/normalize-times.js +5 -0
- package/dist/source/animation/sequence/utils/sort.js +12 -0
- package/dist/source/animation/utils/create-visual-element.js +37 -0
- package/dist/source/animation/utils/is-dom-keyframes.js +3 -0
- package/dist/source/components/AnimatePresence.jsx +444 -0
- package/dist/source/components/AnimatePresenceContext.jsx +20 -0
- package/dist/source/components/AnimatePresenceTypes.js +1 -0
- package/dist/source/components/MotionConfig.jsx +13 -0
- package/dist/source/context/MotionContext/create.js +19 -0
- package/dist/source/context/MotionContext/utils.js +11 -0
- package/dist/source/context/MotionContext.js +2 -0
- package/dist/source/context/PresenceContext.js +2 -0
- package/dist/source/events/add-pointer-event.js +5 -0
- package/dist/source/events/event-info.js +16 -0
- package/dist/source/gestures/drag/VisualElementDragControls.js +531 -0
- package/dist/source/gestures/drag/index.js +47 -0
- package/dist/source/gestures/drag/utils/constraints.js +160 -0
- package/dist/source/gestures/focus.js +37 -0
- package/dist/source/gestures/hover.js +25 -0
- package/dist/source/gestures/pan/PanSession.js +273 -0
- package/dist/source/gestures/pan/index.js +46 -0
- package/dist/source/gestures/press.js +28 -0
- package/dist/source/index.js +11 -0
- package/dist/source/motion/features/animation/exit.js +33 -0
- package/dist/source/motion/features/animation/index.js +27 -0
- package/dist/source/motion/features/animations.js +10 -0
- package/dist/source/motion/features/definitions.js +29 -0
- package/dist/source/motion/features/feature-bundle.js +6 -0
- package/dist/source/motion/features/gestures.js +20 -0
- package/dist/source/motion/features/load-features.js +12 -0
- package/dist/source/motion/index.jsx +176 -0
- package/dist/source/motion/types.js +1 -0
- package/dist/source/motion/utils/drag-projection.js +16 -0
- package/dist/source/motion/utils/use-visual-state.js +53 -0
- package/dist/source/motion/utils/valid-prop.js +40 -0
- package/dist/source/render/dom/create-visual-element.js +10 -0
- package/dist/source/render/dom/filter-props.js +15 -0
- package/dist/source/render/dom/is-svg-component.js +10 -0
- package/dist/source/render/dom/style.js +12 -0
- package/dist/source/render/html/use-props.js +39 -0
- package/dist/source/render/html/utils/create-render-state.js +6 -0
- package/dist/source/render/svg/lowercase-elements.js +27 -0
- package/dist/source/render/svg/use-props.js +28 -0
- package/dist/source/render/svg/utils/create-render-state.js +5 -0
- package/dist/source/render/types.js +1 -0
- package/dist/source/utils/distance.js +7 -0
- package/dist/source/utils/get-context-window.js +4 -0
- package/dist/source/utils/is-ref-object.js +5 -0
- package/dist/source/utils/safe-react-types.js +1 -0
- package/dist/source/utils/use-reduced-motion.js +15 -0
- package/dist/source/value/use-motion-value-event.js +5 -0
- package/dist/source/value/use-motion-value.js +16 -0
- package/dist/source/value/use-spring.js +59 -0
- package/dist/source/value/use-transform.js +25 -0
- package/dist/source/value/use-velocity.js +17 -0
- package/dist/utils/distance.d.ts +3 -0
- package/dist/utils/get-context-window.d.ts +2 -0
- package/dist/utils/is-ref-object.d.ts +2 -0
- package/dist/utils/safe-react-types.d.ts +3 -0
- package/dist/utils/use-reduced-motion.d.ts +6 -0
- package/dist/value/use-motion-value-event.d.ts +3 -0
- package/dist/value/use-motion-value.d.ts +5 -0
- package/dist/value/use-spring.d.ts +5 -0
- package/dist/value/use-transform.d.ts +9 -0
- package/dist/value/use-velocity.d.ts +3 -0
- package/package.json +61 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { PanInfo } from "motion-dom";
|
|
2
|
+
import { TransformPoint } from "motion-utils";
|
|
3
|
+
type PanHandler = (event: PointerEvent, info: PanInfo) => void;
|
|
4
|
+
interface PanSessionHandlers {
|
|
5
|
+
onSessionStart: PanHandler;
|
|
6
|
+
onStart: PanHandler;
|
|
7
|
+
onMove: PanHandler;
|
|
8
|
+
onEnd: PanHandler;
|
|
9
|
+
onSessionEnd: PanHandler;
|
|
10
|
+
resumeAnimation: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface PanSessionOptions {
|
|
13
|
+
transformPagePoint?: TransformPoint;
|
|
14
|
+
dragSnapToOrigin?: boolean;
|
|
15
|
+
distanceThreshold?: number;
|
|
16
|
+
contextWindow?: (Window & typeof globalThis) | null;
|
|
17
|
+
/**
|
|
18
|
+
* Element being dragged. When provided, scroll events on its
|
|
19
|
+
* ancestors and window are compensated so the gesture continues
|
|
20
|
+
* smoothly during scroll.
|
|
21
|
+
*/
|
|
22
|
+
element?: HTMLElement | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare class PanSession {
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
private history;
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
private startEvent;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
private lastMoveEvent;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
private lastMoveEventInfo;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
private transformPagePoint?;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
private handlers;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
private removeListeners;
|
|
56
|
+
/**
|
|
57
|
+
* For determining if an animation should resume after it is interupted
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
private dragSnapToOrigin;
|
|
62
|
+
/**
|
|
63
|
+
* The distance after which panning should start.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
private distanceThreshold;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
private contextWindow;
|
|
72
|
+
/**
|
|
73
|
+
* Scroll positions of scrollable ancestors and window.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
private scrollPositions;
|
|
77
|
+
/**
|
|
78
|
+
* Cleanup function for scroll listeners.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
private removeScrollListeners;
|
|
82
|
+
constructor(event: PointerEvent, handlers: Partial<PanSessionHandlers>, { transformPagePoint, contextWindow, dragSnapToOrigin, distanceThreshold, element, }?: PanSessionOptions);
|
|
83
|
+
/**
|
|
84
|
+
* Start tracking scroll on ancestors and window.
|
|
85
|
+
*/
|
|
86
|
+
private startScrollTracking;
|
|
87
|
+
private onElementScroll;
|
|
88
|
+
private onWindowScroll;
|
|
89
|
+
/**
|
|
90
|
+
* Handle scroll compensation during drag.
|
|
91
|
+
*
|
|
92
|
+
* For element scroll: adjusts history origin since pageX/pageY doesn't change.
|
|
93
|
+
* For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.
|
|
94
|
+
*/
|
|
95
|
+
private handleScroll;
|
|
96
|
+
private updatePoint;
|
|
97
|
+
private handlePointerMove;
|
|
98
|
+
private handlePointerUp;
|
|
99
|
+
updateHandlers(handlers: Partial<PanSessionHandlers>): void;
|
|
100
|
+
end(): void;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Feature, type PanInfo } from "motion-dom";
|
|
2
|
+
export declare class PanGesture extends Feature<Element> {
|
|
3
|
+
private session?;
|
|
4
|
+
private removePointerDownListener;
|
|
5
|
+
onPointerDown(pointerDownEvent: PointerEvent): void;
|
|
6
|
+
createPanHandlers(): {
|
|
7
|
+
onSessionStart: (event: PointerEvent, info: PanInfo) => void;
|
|
8
|
+
onStart: (event: PointerEvent, info: PanInfo) => void;
|
|
9
|
+
onMove: ((event: PointerEvent, info: PanInfo) => void) | undefined;
|
|
10
|
+
onEnd: (event: PointerEvent, info: PanInfo) => void;
|
|
11
|
+
};
|
|
12
|
+
mount(): void;
|
|
13
|
+
update(): void;
|
|
14
|
+
unmount(): void;
|
|
15
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { motion, m, createMotionComponent } from "./motion";
|
|
2
|
+
export { MotionConfig } from "./components/MotionConfig";
|
|
3
|
+
export { AnimatePresence, usePresence, useIsPresent } from "./components/AnimatePresence";
|
|
4
|
+
export type { AnimatePresenceProps } from "./components/AnimatePresenceTypes.js";
|
|
5
|
+
export type { MotionProps, MotionStyle } from "./motion/types";
|
|
6
|
+
export { useMotionValue } from "./value/use-motion-value";
|
|
7
|
+
export { useTransform } from "./value/use-transform";
|
|
8
|
+
export { useSpring } from "./value/use-spring";
|
|
9
|
+
export { useVelocity } from "./value/use-velocity";
|
|
10
|
+
export { useMotionValueEvent } from "./value/use-motion-value-event";
|
|
11
|
+
export { useReducedMotion } from "./utils/use-reduced-motion";
|
|
12
|
+
export { animate, createScopedAnimate } from "./animation/animate";
|
|
13
|
+
export * from "motion-dom";
|