@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
package/LICENSE
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kit Langton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Portions of this package (gesture, pointer-event and related utilities) are
|
|
26
|
+
adapted from framer-motion, under the following license:
|
|
27
|
+
|
|
28
|
+
The MIT License (MIT)
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2018 Framer B.V.
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @kitlangton/solid-motion
|
|
2
|
+
|
|
3
|
+
[Motion](https://motion.dev) for SolidJS. The same animation engine, springs and
|
|
4
|
+
gestures, with a `motion.*` API that uses Solid's fine-grained reactivity.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @kitlangton/solid-motion solid-js
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { motion } from "@kitlangton/solid-motion"
|
|
12
|
+
|
|
13
|
+
<motion.button
|
|
14
|
+
animate={{ scale: active() ? 1.1 : 1 }}
|
|
15
|
+
whileHover={{ y: -2 }}
|
|
16
|
+
whileTap={{ scale: 0.95 }}
|
|
17
|
+
transition={{ type: "spring", visualDuration: 0.22, bounce: 0.1 }}
|
|
18
|
+
/>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Presence
|
|
22
|
+
|
|
23
|
+
Keep `AnimatePresence` mounted and pass a child factory, so the exiting element
|
|
24
|
+
can be retained until its exit animation finishes:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<AnimatePresence when={open()}>
|
|
28
|
+
{() => <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} />}
|
|
29
|
+
</AnimatePresence>
|
|
30
|
+
|
|
31
|
+
// Switch between keyed children
|
|
32
|
+
<AnimatePresence when={true} presenceKey={tab()}>
|
|
33
|
+
{() => <motion.div exit={{ opacity: 0 }}>{tab()}</motion.div>}
|
|
34
|
+
</AnimatePresence>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Gestures and drag
|
|
38
|
+
|
|
39
|
+
`whileHover`, `whileTap`, `whileFocus`, `whileDrag`, `drag`, `dragConstraints`
|
|
40
|
+
(box or `{ current: element }`), `dragElastic`, `dragMomentum` and
|
|
41
|
+
`onDragEnd(event, { offset, velocity })` follow Motion's semantics.
|
|
42
|
+
|
|
43
|
+
## Motion values
|
|
44
|
+
|
|
45
|
+
`useMotionValue`, `useTransform`, `useSpring`, `useVelocity`,
|
|
46
|
+
`useMotionValueEvent`, `animate`, and `useReducedMotion` (returns an accessor).
|
|
47
|
+
Motion values update the DOM directly without re-running components.
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
|
|
51
|
+
- Specify `bounce` whenever you use `visualDuration` (the pinned engine,
|
|
52
|
+
`motion-dom@12.30`, ignores `visualDuration` on its own).
|
|
53
|
+
- Layout animations (`layout`, `layoutId`) are not implemented yet.
|
|
54
|
+
- Gesture implementations are adapted from `framer-motion@12.30.0` (MIT).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AnimationPlaybackControlsWithThen, AnimationScope, DOMKeyframesDefinition, AnimationOptions as DynamicAnimationOptions, ElementOrSelector, MotionValue, UnresolvedValueKeyframe, ValueAnimationTransition } from "motion-dom";
|
|
2
|
+
import type { AnimationSequence, ObjectTarget, SequenceOptions } from "../sequence/types";
|
|
3
|
+
interface ScopedAnimateOptions {
|
|
4
|
+
scope?: AnimationScope;
|
|
5
|
+
reduceMotion?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function createScopedAnimate(options?: ScopedAnimateOptions): {
|
|
8
|
+
(sequence: AnimationSequence, options?: SequenceOptions): AnimationPlaybackControlsWithThen;
|
|
9
|
+
(value: string | MotionValue<string>, keyframes: string | UnresolvedValueKeyframe<string>[], options?: ValueAnimationTransition<string>): AnimationPlaybackControlsWithThen;
|
|
10
|
+
(value: number | MotionValue<number>, keyframes: number | UnresolvedValueKeyframe<number>[], options?: ValueAnimationTransition<number>): AnimationPlaybackControlsWithThen;
|
|
11
|
+
<V extends string | number>(value: V | MotionValue<V>, keyframes: V | UnresolvedValueKeyframe<V>[], options?: ValueAnimationTransition<V>): AnimationPlaybackControlsWithThen;
|
|
12
|
+
(element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions): AnimationPlaybackControlsWithThen;
|
|
13
|
+
<O extends {}>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions): AnimationPlaybackControlsWithThen;
|
|
14
|
+
};
|
|
15
|
+
export declare const animate: {
|
|
16
|
+
(sequence: AnimationSequence, options?: SequenceOptions): AnimationPlaybackControlsWithThen;
|
|
17
|
+
(value: string | MotionValue<string>, keyframes: string | UnresolvedValueKeyframe<string>[], options?: ValueAnimationTransition<string>): AnimationPlaybackControlsWithThen;
|
|
18
|
+
(value: number | MotionValue<number>, keyframes: number | UnresolvedValueKeyframe<number>[], options?: ValueAnimationTransition<number>): AnimationPlaybackControlsWithThen;
|
|
19
|
+
<V extends string | number>(value: V | MotionValue<V>, keyframes: V | UnresolvedValueKeyframe<V>[], options?: ValueAnimationTransition<V>): AnimationPlaybackControlsWithThen;
|
|
20
|
+
(element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions): AnimationPlaybackControlsWithThen;
|
|
21
|
+
<O extends {}>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions): AnimationPlaybackControlsWithThen;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AnimationScope, DOMKeyframesDefinition, SelectorCache } from "motion-dom";
|
|
2
|
+
import type { ObjectTarget } from "../sequence/types";
|
|
3
|
+
export declare function resolveSubjects<O extends {}>(subject: string | Element | Element[] | NodeListOf<Element> | O | O[] | null | undefined, keyframes: DOMKeyframesDefinition | ObjectTarget<O>, scope?: AnimationScope, selectorCache?: SelectorCache): (string | Element | O)[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AnimationPlaybackControlsWithThen, AnimationScope } from "motion-dom";
|
|
2
|
+
import type { AnimationSequence, SequenceOptions } from "../sequence/types";
|
|
3
|
+
export declare function animateSequence(sequence: AnimationSequence, options?: SequenceOptions, scope?: AnimationScope): AnimationPlaybackControlsWithThen[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnimationPlaybackControlsWithThen, AnimationScope, DOMKeyframesDefinition, AnimationOptions as DynamicAnimationOptions, ElementOrSelector, MotionValue, UnresolvedValueKeyframe, ValueAnimationTransition } from "motion-dom";
|
|
2
|
+
import type { ObjectTarget } from "../sequence/types";
|
|
3
|
+
export type AnimationSubject = Element | MotionValue<any> | any;
|
|
4
|
+
export declare function animateSubject(value: string | MotionValue<string>, keyframes: string | UnresolvedValueKeyframe<string>[], options?: ValueAnimationTransition<string>): AnimationPlaybackControlsWithThen[];
|
|
5
|
+
export declare function animateSubject(value: number | MotionValue<number>, keyframes: number | UnresolvedValueKeyframe<number>[], options?: ValueAnimationTransition<number>): AnimationPlaybackControlsWithThen[];
|
|
6
|
+
export declare function animateSubject(element: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions, scope?: AnimationScope): AnimationPlaybackControlsWithThen[];
|
|
7
|
+
export declare function animateSubject<O extends Object>(object: O | O[], keyframes: ObjectTarget<O>, options?: DynamicAnimationOptions): AnimationPlaybackControlsWithThen[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnimationScope, AnimationOptions as DynamicAnimationOptions, GeneratorFactory } from "motion-dom";
|
|
2
|
+
import { AnimationSequence, At, ResolvedAnimationDefinitions, SequenceOptions } from "./types";
|
|
3
|
+
export declare function createAnimationsFromSequence(sequence: AnimationSequence, { defaultTransition, ...sequenceTransition }?: SequenceOptions, scope?: AnimationScope, generators?: {
|
|
4
|
+
[key: string]: GeneratorFactory;
|
|
5
|
+
}): ResolvedAnimationDefinitions;
|
|
6
|
+
export declare function getValueTransition(transition: DynamicAnimationOptions & At, key: string): DynamicAnimationOptions;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AnyResolvedKeyframe, MotionValue } from "motion-dom";
|
|
2
|
+
import { AnimationPlaybackOptions, DOMKeyframesDefinition, AnimationOptions as DynamicAnimationOptions, ElementOrSelector, Transition, UnresolvedValueKeyframe } from "motion-dom";
|
|
3
|
+
import { Easing } from "motion-utils";
|
|
4
|
+
export type ObjectTarget<O> = {
|
|
5
|
+
[K in keyof O]?: O[K] | UnresolvedValueKeyframe[];
|
|
6
|
+
};
|
|
7
|
+
export type SequenceTime = number | "<" | `+${number}` | `-${number}` | `${string}`;
|
|
8
|
+
export type SequenceLabel = string;
|
|
9
|
+
export interface SequenceLabelWithTime {
|
|
10
|
+
name: SequenceLabel;
|
|
11
|
+
at: SequenceTime;
|
|
12
|
+
}
|
|
13
|
+
export interface At {
|
|
14
|
+
at?: SequenceTime;
|
|
15
|
+
}
|
|
16
|
+
export type MotionValueSegment = [MotionValue, UnresolvedValueKeyframe | UnresolvedValueKeyframe[]];
|
|
17
|
+
export type MotionValueSegmentWithTransition = [
|
|
18
|
+
MotionValue,
|
|
19
|
+
UnresolvedValueKeyframe | UnresolvedValueKeyframe[],
|
|
20
|
+
Transition & At
|
|
21
|
+
];
|
|
22
|
+
export type DOMSegment = [ElementOrSelector, DOMKeyframesDefinition];
|
|
23
|
+
export type DOMSegmentWithTransition = [ElementOrSelector, DOMKeyframesDefinition, DynamicAnimationOptions & At];
|
|
24
|
+
export type ObjectSegment<O extends {} = {}> = [O, ObjectTarget<O>];
|
|
25
|
+
export type ObjectSegmentWithTransition<O extends {} = {}> = [O, ObjectTarget<O>, DynamicAnimationOptions & At];
|
|
26
|
+
export type Segment = ObjectSegment | ObjectSegmentWithTransition | SequenceLabel | SequenceLabelWithTime | MotionValueSegment | MotionValueSegmentWithTransition | DOMSegment | DOMSegmentWithTransition;
|
|
27
|
+
export type AnimationSequence = Segment[];
|
|
28
|
+
export interface SequenceOptions extends AnimationPlaybackOptions {
|
|
29
|
+
delay?: number;
|
|
30
|
+
duration?: number;
|
|
31
|
+
defaultTransition?: Transition;
|
|
32
|
+
reduceMotion?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface AbsoluteKeyframe {
|
|
35
|
+
value: AnyResolvedKeyframe | null;
|
|
36
|
+
at: number;
|
|
37
|
+
easing?: Easing;
|
|
38
|
+
}
|
|
39
|
+
export type ValueSequence = AbsoluteKeyframe[];
|
|
40
|
+
export interface SequenceMap {
|
|
41
|
+
[key: string]: ValueSequence;
|
|
42
|
+
}
|
|
43
|
+
export type ResolvedAnimationDefinition = {
|
|
44
|
+
keyframes: {
|
|
45
|
+
[key: string]: UnresolvedValueKeyframe[];
|
|
46
|
+
};
|
|
47
|
+
transition: {
|
|
48
|
+
[key: string]: Transition;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type ResolvedAnimationDefinitions = Map<Element | MotionValue, ResolvedAnimationDefinition>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function calculateRepeatDuration(duration: number, repeat: number, _repeatDelay: number): number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UnresolvedValueKeyframe } from "motion-dom";
|
|
2
|
+
import { Easing } from "motion-utils";
|
|
3
|
+
import type { ValueSequence } from "../types";
|
|
4
|
+
export declare function eraseKeyframes(sequence: ValueSequence, startTime: number, endTime: number): void;
|
|
5
|
+
export declare function addKeyframes(sequence: ValueSequence, keyframes: UnresolvedValueKeyframe[], easing: Easing | Easing[], offset: number[], startTime: number, endTime: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeTimes(times: number[], repeat: number): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnimatePresenceProps } from "./AnimatePresenceTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* AnimatePresence for Solid.js
|
|
4
|
+
*
|
|
5
|
+
* Enables exit animations by keeping elements in the DOM
|
|
6
|
+
* until their exit animations complete.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```solid
|
|
10
|
+
* <AnimatePresence>
|
|
11
|
+
* {show() && (
|
|
12
|
+
* <motion.div
|
|
13
|
+
* exit={{ opacity: 0 }}
|
|
14
|
+
* />
|
|
15
|
+
* )}
|
|
16
|
+
* </AnimatePresence>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function AnimatePresence(props: AnimatePresenceProps): import("solid-js").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Hook to access presence state and signal safe removal
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePresence(): [boolean, (() => void) | null];
|
|
24
|
+
/**
|
|
25
|
+
* Simple hook to check if component is present
|
|
26
|
+
*/
|
|
27
|
+
export declare function useIsPresent(): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Accessor } from "solid-js";
|
|
2
|
+
import type { PresenceContextProps } from "motion-dom";
|
|
3
|
+
export type { PresenceContextProps };
|
|
4
|
+
export interface SolidPresenceContext extends Omit<PresenceContextProps, 'id' | 'isPresent' | 'initial' | 'custom'> {
|
|
5
|
+
id: Accessor<string>;
|
|
6
|
+
isPresent: Accessor<boolean>;
|
|
7
|
+
initial: Accessor<false | string | string[] | undefined>;
|
|
8
|
+
custom: Accessor<any>;
|
|
9
|
+
}
|
|
10
|
+
export declare const AnimatePresenceContext: import("solid-js").Context<SolidPresenceContext | null>;
|
|
11
|
+
export declare function AnimatePresenceProvider(props: {
|
|
12
|
+
value: SolidPresenceContext;
|
|
13
|
+
children: any;
|
|
14
|
+
}): import("solid-js").JSX.Element;
|
|
15
|
+
export declare function createPresenceState(config: {
|
|
16
|
+
id: Accessor<string>;
|
|
17
|
+
isPresent: Accessor<boolean>;
|
|
18
|
+
initial: Accessor<false | string | string[] | undefined>;
|
|
19
|
+
custom?: Accessor<any>;
|
|
20
|
+
onExitComplete?: (childId: string | number) => void;
|
|
21
|
+
register?: (childId: string | number) => () => void;
|
|
22
|
+
}): SolidPresenceContext;
|
|
23
|
+
export declare function usePresenceInternal(): SolidPresenceContext | null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
export type ChildKey = string | number | object;
|
|
3
|
+
export interface PresenceChildState {
|
|
4
|
+
key: ChildKey;
|
|
5
|
+
getChild: () => any;
|
|
6
|
+
isPresent: boolean;
|
|
7
|
+
index: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AnimatePresenceProps {
|
|
10
|
+
/**
|
|
11
|
+
* Children to animate. Can be a single element or multiple elements.
|
|
12
|
+
* Multiple elements must have unique `key` props.
|
|
13
|
+
*/
|
|
14
|
+
children?: JSX.Element | (() => JSX.Element);
|
|
15
|
+
/**
|
|
16
|
+
* When defined, drives presence without evaluating children.
|
|
17
|
+
*/
|
|
18
|
+
when?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Key for the current child when using `when`.
|
|
21
|
+
*/
|
|
22
|
+
presenceKey?: ChildKey;
|
|
23
|
+
/**
|
|
24
|
+
* If `false`, will disable the first animation on mount.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
initial?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callback when all exiting animations have completed.
|
|
30
|
+
*/
|
|
31
|
+
onExitComplete?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Animation coordination mode:
|
|
34
|
+
* - "sync" (default): All animations happen simultaneously
|
|
35
|
+
* - "wait": Wait for exit animations to complete before enter animations
|
|
36
|
+
* - "popLayout": Keep exiting elements in layout until they finish
|
|
37
|
+
* @default "sync"
|
|
38
|
+
*/
|
|
39
|
+
mode?: "sync" | "wait" | "popLayout";
|
|
40
|
+
/**
|
|
41
|
+
* Custom data to pass to all variants through the custom prop
|
|
42
|
+
*/
|
|
43
|
+
custom?: any;
|
|
44
|
+
/**
|
|
45
|
+
* Whether presence affects layout calculations
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
presenceAffectsLayout?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* For popLayout mode: which edge to anchor exiting elements
|
|
51
|
+
*/
|
|
52
|
+
anchorX?: "left" | "right";
|
|
53
|
+
/**
|
|
54
|
+
* For popLayout mode: root element for positioning
|
|
55
|
+
*/
|
|
56
|
+
root?: HTMLElement | ShadowRoot;
|
|
57
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSX } from "solid-js";
|
|
2
|
+
import type { TransformPoint } from "motion-utils";
|
|
3
|
+
import type { Transition } from "motion-dom";
|
|
4
|
+
export type ReducedMotionConfig = "always" | "never" | "user";
|
|
5
|
+
export interface MotionConfigContext {
|
|
6
|
+
transformPagePoint: TransformPoint;
|
|
7
|
+
isStatic: boolean;
|
|
8
|
+
transition?: Transition;
|
|
9
|
+
reducedMotion?: ReducedMotionConfig;
|
|
10
|
+
nonce?: string;
|
|
11
|
+
skipAnimations?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const MotionConfigContext: import("solid-js").Context<MotionConfigContext>;
|
|
14
|
+
export declare function MotionConfig(props: Partial<MotionConfigContext> & {
|
|
15
|
+
children?: JSX.Element;
|
|
16
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VisualElement } from "motion-dom";
|
|
2
|
+
export interface MotionContextProps<Instance = unknown> {
|
|
3
|
+
visualElement?: VisualElement<Instance>;
|
|
4
|
+
initial?: false | string | string[];
|
|
5
|
+
animate?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const MotionContext: import("solid-js").Context<MotionContextProps<unknown>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Accessor } from "solid-js";
|
|
2
|
+
import type { PresenceContextProps as MotionDomPresenceContextProps } from "motion-dom";
|
|
3
|
+
import type { VariantLabels } from "../motion/types";
|
|
4
|
+
export type { MotionDomPresenceContextProps as ResolvedPresenceContextProps };
|
|
5
|
+
export interface PresenceContextProps {
|
|
6
|
+
id: Accessor<string>;
|
|
7
|
+
isPresent: Accessor<boolean>;
|
|
8
|
+
register?: (id: string | number) => () => void;
|
|
9
|
+
onExitComplete?: (id: string | number) => void;
|
|
10
|
+
initial: Accessor<false | VariantLabels | undefined>;
|
|
11
|
+
custom: Accessor<any>;
|
|
12
|
+
}
|
|
13
|
+
export declare const PresenceContext: import("solid-js").Context<PresenceContextProps | null>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EventInfo } from "motion-dom";
|
|
2
|
+
export type EventListenerWithPointInfo = (e: PointerEvent, info: EventInfo) => void;
|
|
3
|
+
export declare function extractEventInfo(event: PointerEvent): EventInfo;
|
|
4
|
+
export declare const addPointerInfo: (handler: EventListenerWithPointInfo) => EventListener;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PanInfo, type VisualElement } from "motion-dom";
|
|
2
|
+
import { MotionProps } from "../../motion/types";
|
|
3
|
+
export declare const elementDragControls: WeakMap<VisualElement<unknown, unknown, {}>, VisualElementDragControls>;
|
|
4
|
+
export interface DragControlOptions {
|
|
5
|
+
/**
|
|
6
|
+
* This distance after which dragging starts and a direction is locked in.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
distanceThreshold?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to immediately snap to the cursor when dragging starts.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
snapToCursor?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class VisualElementDragControls {
|
|
19
|
+
private visualElement;
|
|
20
|
+
private panSession?;
|
|
21
|
+
private openDragLock;
|
|
22
|
+
isDragging: boolean;
|
|
23
|
+
private currentDirection;
|
|
24
|
+
private originPoint;
|
|
25
|
+
/**
|
|
26
|
+
* The permitted boundaries of travel, in pixels.
|
|
27
|
+
*/
|
|
28
|
+
private constraints;
|
|
29
|
+
private hasMutatedConstraints;
|
|
30
|
+
/**
|
|
31
|
+
* The per-axis resolved elastic values.
|
|
32
|
+
*/
|
|
33
|
+
private elastic;
|
|
34
|
+
/**
|
|
35
|
+
* The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.
|
|
36
|
+
*/
|
|
37
|
+
private latestPointerEvent;
|
|
38
|
+
/**
|
|
39
|
+
* The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.
|
|
40
|
+
*/
|
|
41
|
+
private latestPanInfo;
|
|
42
|
+
constructor(visualElement: VisualElement<HTMLElement>);
|
|
43
|
+
start(originEvent: PointerEvent, { snapToCursor, distanceThreshold }?: DragControlOptions): void;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
stop(event?: PointerEvent, panInfo?: PanInfo): void;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
cancel(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Clean up the pan session without modifying other drag state.
|
|
54
|
+
* This is used during unmount to ensure event listeners are removed
|
|
55
|
+
* without affecting projection animations or drag locks.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
endPanSession(): void;
|
|
59
|
+
/** Final owner disposal, including any release inertia on external values. */
|
|
60
|
+
dispose(): void;
|
|
61
|
+
private updateAxis;
|
|
62
|
+
private resolveConstraints;
|
|
63
|
+
private resolveRefConstraints;
|
|
64
|
+
private startAnimation;
|
|
65
|
+
private startAxisValueAnimation;
|
|
66
|
+
private stopAnimation;
|
|
67
|
+
private pauseAnimation;
|
|
68
|
+
private getAnimationState;
|
|
69
|
+
/**
|
|
70
|
+
* Drag works differently depending on which props are provided.
|
|
71
|
+
*
|
|
72
|
+
* - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
|
|
73
|
+
* - Otherwise, we apply the delta to the x/y motion values.
|
|
74
|
+
*/
|
|
75
|
+
private getAxisMotionValue;
|
|
76
|
+
private snapToCursor;
|
|
77
|
+
/**
|
|
78
|
+
* When the viewport resizes we want to check if the measured constraints
|
|
79
|
+
* have changed and, if so, reposition the element within those new constraints
|
|
80
|
+
* relative to where it was before the resize.
|
|
81
|
+
*/
|
|
82
|
+
scalePositionWithinConstraints(): void;
|
|
83
|
+
addListeners(): (() => void) | undefined;
|
|
84
|
+
getProps(): MotionProps;
|
|
85
|
+
}
|
|
86
|
+
export declare function expectsResolvedDragConstraints({ dragConstraints, onMeasureDragConstraints, }: MotionProps): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Feature, type VisualElement } from "motion-dom";
|
|
2
|
+
import { VisualElementDragControls } from "./VisualElementDragControls";
|
|
3
|
+
export declare class DragGesture extends Feature<HTMLElement> {
|
|
4
|
+
controls: VisualElementDragControls;
|
|
5
|
+
removeGroupControls: Function;
|
|
6
|
+
removeListeners: Function;
|
|
7
|
+
constructor(node: VisualElement<HTMLElement>);
|
|
8
|
+
mount(): void;
|
|
9
|
+
update(): void;
|
|
10
|
+
unmount(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type DragElastic, type ResolvedConstraints } from "motion-dom";
|
|
2
|
+
import { Axis, BoundingBox, Box, Point } from "motion-utils";
|
|
3
|
+
/**
|
|
4
|
+
* Apply constraints to a point. These constraints are both physical along an
|
|
5
|
+
* axis, and an elastic factor that determines how much to constrain the point
|
|
6
|
+
* by if it does lie outside the defined parameters.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyConstraints(point: number, { min, max }: Partial<Axis>, elastic?: Axis): number;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates a min projection point based on a pointer, pointer progress
|
|
11
|
+
* within the drag target, and constraints.
|
|
12
|
+
*
|
|
13
|
+
* For instance if an element was 100px width, we were dragging from 0.25
|
|
14
|
+
* along this axis, the pointer is at 200px, and there were no constraints,
|
|
15
|
+
* we would calculate a min projection point of 175px.
|
|
16
|
+
*/
|
|
17
|
+
export declare function calcConstrainedMinPoint(point: number, length: number, progress: number, constraints?: Partial<Axis>, elastic?: Axis): number;
|
|
18
|
+
/**
|
|
19
|
+
* Calculate constraints in terms of the viewport when defined relatively to the
|
|
20
|
+
* measured axis. This is measured from the nearest edge, so a max constraint of 200
|
|
21
|
+
* on an axis with a max value of 300 would return a constraint of 500 - axis length
|
|
22
|
+
*/
|
|
23
|
+
export declare function calcRelativeAxisConstraints(axis: Axis, min?: number, max?: number): Partial<Axis>;
|
|
24
|
+
/**
|
|
25
|
+
* Calculate constraints in terms of the viewport when
|
|
26
|
+
* defined relatively to the measured bounding box.
|
|
27
|
+
*/
|
|
28
|
+
export declare function calcRelativeConstraints(layoutBox: Box, { top, left, bottom, right }: Partial<BoundingBox>): ResolvedConstraints;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate viewport constraints when defined as another viewport-relative axis
|
|
31
|
+
*/
|
|
32
|
+
export declare function calcViewportAxisConstraints(layoutAxis: Axis, constraintsAxis: Axis): {
|
|
33
|
+
min: number;
|
|
34
|
+
max: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Calculate viewport constraints when defined as another viewport-relative box
|
|
38
|
+
*/
|
|
39
|
+
export declare function calcViewportConstraints(layoutBox: Box, constraintsBox: Box): {
|
|
40
|
+
x: {
|
|
41
|
+
min: number;
|
|
42
|
+
max: number;
|
|
43
|
+
};
|
|
44
|
+
y: {
|
|
45
|
+
min: number;
|
|
46
|
+
max: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Calculate a transform origin relative to the source axis, between 0-1, that results
|
|
51
|
+
* in an asthetically pleasing scale/transform needed to project from source to target.
|
|
52
|
+
*/
|
|
53
|
+
export declare function calcOrigin(source: Axis, target: Axis): number;
|
|
54
|
+
/**
|
|
55
|
+
* Calculate the relative progress of one constraints box relative to another.
|
|
56
|
+
* Imagine a page scroll bar. At the top, this would return 0, at the bottom, 1.
|
|
57
|
+
* Anywhere in-between, a value between 0 and 1.
|
|
58
|
+
*
|
|
59
|
+
* This also handles flipped constraints, for instance a draggable container within
|
|
60
|
+
* a smaller viewport like a scrollable view.
|
|
61
|
+
*/
|
|
62
|
+
export declare function calcProgressWithinConstraints(layoutBox: Box, constraintsBox: Box): Point;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate the an axis position based on two axes and a progress value.
|
|
65
|
+
*/
|
|
66
|
+
export declare function calcPositionFromProgress(axis: Axis, constraints: Axis, progress: number): Axis;
|
|
67
|
+
/**
|
|
68
|
+
* Rebase the calculated viewport constraints relative to the layout.min point.
|
|
69
|
+
*/
|
|
70
|
+
export declare function rebaseAxisConstraints(layout: Axis, constraints: Partial<Axis>): Partial<Axis>;
|
|
71
|
+
export declare const defaultElastic = 0.35;
|
|
72
|
+
/**
|
|
73
|
+
* Accepts a dragElastic prop and returns resolved elastic values for each axis.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveDragElastic(dragElastic?: DragElastic): Box;
|
|
76
|
+
export declare function resolveAxisElastic(dragElastic: DragElastic, minLabel: string, maxLabel: string): Axis;
|
|
77
|
+
export declare function resolvePointElastic(dragElastic: DragElastic, label: string): number;
|