motion-start 0.0.1
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 +21 -0
- package/README.md +39 -0
- package/package.json +64 -0
- package/src/animation/UseAnimatedState.svelte +86 -0
- package/src/animation/UseAnimation.svelte +61 -0
- package/src/animation/animate.ts +78 -0
- package/src/animation/animation-controls.ts +101 -0
- package/src/animation/types.ts +83 -0
- package/src/animation/use-animated-state.ts +1 -0
- package/src/animation/use-animation.ts +74 -0
- package/src/animation/utils/default-transitions.ts +70 -0
- package/src/animation/utils/easing.ts +55 -0
- package/src/animation/utils/is-animatable.ts +42 -0
- package/src/animation/utils/is-animation-controls.ts +17 -0
- package/src/animation/utils/is-keyframes-target.ts +17 -0
- package/src/animation/utils/transitions.ts +218 -0
- package/src/animation/utils/variant-resolvers.ts +15 -0
- package/src/components/AnimatePresence/AnimatePresence.svelte +180 -0
- package/src/components/AnimatePresence/PresenceChild/PresenceChild.svelte +78 -0
- package/src/components/AnimatePresence/PresenceChild/index.ts +7 -0
- package/src/components/AnimatePresence/PresenceChild/types.ts +10 -0
- package/src/components/AnimatePresence/index.ts +46 -0
- package/src/components/AnimatePresence/types.ts +79 -0
- package/src/components/AnimatePresence/use-presence.ts +90 -0
- package/src/components/AnimateSharedLayout/AnimateSharedLayout.svelte +239 -0
- package/src/components/AnimateSharedLayout/index.ts +11 -0
- package/src/components/AnimateSharedLayout/types.ts +111 -0
- package/src/components/AnimateSharedLayout/utils/batcher.ts +96 -0
- package/src/components/AnimateSharedLayout/utils/crossfader.ts +260 -0
- package/src/components/AnimateSharedLayout/utils/rotate.ts +48 -0
- package/src/components/AnimateSharedLayout/utils/stack.ts +160 -0
- package/src/components/LazyMotion/LazyMotion.svelte +82 -0
- package/src/components/LazyMotion/index.ts +42 -0
- package/src/components/LazyMotion/types.ts +58 -0
- package/src/components/MotionConfig/MotionConfig.svelte +56 -0
- package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +47 -0
- package/src/components/MotionConfig/index.ts +20 -0
- package/src/components/MotionDiv.svelte +8 -0
- package/src/context/DOMcontext.ts +21 -0
- package/src/context/LayoutGroupContext.ts +13 -0
- package/src/context/LazyContext.ts +18 -0
- package/src/context/MotionConfigContext.ts +48 -0
- package/src/context/MotionContext/MotionContext.svelte +27 -0
- package/src/context/MotionContext/MotionContextProvider.svelte +22 -0
- package/src/context/MotionContext/UseCreateMotionContext.svelte +34 -0
- package/src/context/MotionContext/create.ts +1 -0
- package/src/context/MotionContext/index.ts +14 -0
- package/src/context/MotionContext/utils.ts +29 -0
- package/src/context/PresenceContext.ts +26 -0
- package/src/context/ScaleCorrectionProvider.svelte +27 -0
- package/src/context/SharedLayoutContext.ts +29 -0
- package/src/events/UseDomEvent.svelte +67 -0
- package/src/events/UsePointerEvent.svelte +76 -0
- package/src/events/event-info.ts +69 -0
- package/src/events/types.ts +15 -0
- package/src/events/use-dom-event.ts +48 -0
- package/src/events/use-pointer-event.ts +29 -0
- package/src/events/utils.ts +25 -0
- package/src/gestures/PanSession.ts +298 -0
- package/src/gestures/UseFocusGesture.svelte +31 -0
- package/src/gestures/UseGestures.svelte +17 -0
- package/src/gestures/UseHoverGesture.svelte +40 -0
- package/src/gestures/UsePanGesture.svelte +58 -0
- package/src/gestures/UseTapGesture.svelte +77 -0
- package/src/gestures/drag/UseDrag.svelte +55 -0
- package/src/gestures/drag/UseDragControls.svelte +145 -0
- package/src/gestures/drag/VisualElementDragControls.ts +632 -0
- package/src/gestures/drag/types.ts +307 -0
- package/src/gestures/drag/use-drag-controls.ts +148 -0
- package/src/gestures/drag/use-drag.ts +15 -0
- package/src/gestures/drag/utils/constraints.ts +157 -0
- package/src/gestures/drag/utils/lock.ts +69 -0
- package/src/gestures/types.ts +257 -0
- package/src/gestures/use-focus-gesture.ts +16 -0
- package/src/gestures/use-gestures.ts +2 -0
- package/src/gestures/use-hover-gesture.ts +10 -0
- package/src/gestures/use-pan-gesture.ts +22 -0
- package/src/gestures/use-tap-gesture.ts +14 -0
- package/src/gestures/utils/event-type.ts +24 -0
- package/src/gestures/utils/is-node-or-child.ts +31 -0
- package/src/index.ts +104 -0
- package/src/motion/Motion.svelte +246 -0
- package/src/motion/MotionSSR.svelte +244 -0
- package/src/motion/features/AnimationState.svelte +29 -0
- package/src/motion/features/Exit.svelte +32 -0
- package/src/motion/features/UseFeatures.svelte +39 -0
- package/src/motion/features/animations.ts +22 -0
- package/src/motion/features/definitions.ts +49 -0
- package/src/motion/features/drag.ts +24 -0
- package/src/motion/features/gestures.ts +24 -0
- package/src/motion/features/layout/Animate.svelte +314 -0
- package/src/motion/features/layout/Animate.ts +9 -0
- package/src/motion/features/layout/AnimateLayoutContextProvider.svelte +14 -0
- package/src/motion/features/layout/Measure.svelte +98 -0
- package/src/motion/features/layout/Measure.ts +9 -0
- package/src/motion/features/layout/MeasureContextProvider.svelte +32 -0
- package/src/motion/features/layout/index.ts +20 -0
- package/src/motion/features/layout/types.ts +71 -0
- package/src/motion/features/layout/utils.ts +40 -0
- package/src/motion/features/types.ts +53 -0
- package/src/motion/features/use-features.ts +16 -0
- package/src/motion/index.ts +64 -0
- package/src/motion/types.ts +278 -0
- package/src/motion/utils/UseLayoutId.svelte +18 -0
- package/src/motion/utils/UseVisualElement.svelte +104 -0
- package/src/motion/utils/UseVisualState.svelte +137 -0
- package/src/motion/utils/is-forced-motion-value.ts +23 -0
- package/src/motion/utils/make-renderless-component.ts +17 -0
- package/src/motion/utils/should-inhert-variant.ts +6 -0
- package/src/motion/utils/use-motion-ref.ts +41 -0
- package/src/motion/utils/use-visual-element.ts +13 -0
- package/src/motion/utils/use-visual-state.ts +24 -0
- package/src/motion/utils/valid-prop.ts +80 -0
- package/src/render/dom/M.svelte +16 -0
- package/src/render/dom/UseRender.svelte +37 -0
- package/src/render/dom/create-motion-class.ts +12 -0
- package/src/render/dom/create-visual-element.ts +22 -0
- package/src/render/dom/featureBundle.ts +22 -0
- package/src/render/dom/motion-minimal.ts +22 -0
- package/src/render/dom/motion-proxy.ts +107 -0
- package/src/render/dom/motion.ts +62 -0
- package/src/render/dom/projection/convert-to-relative.ts +40 -0
- package/src/render/dom/projection/default-scale-correctors.ts +138 -0
- package/src/render/dom/projection/measure.ts +28 -0
- package/src/render/dom/projection/relative-set.ts +27 -0
- package/src/render/dom/projection/scale-correction.ts +22 -0
- package/src/render/dom/projection/types.ts +13 -0
- package/src/render/dom/projection/utils.ts +69 -0
- package/src/render/dom/svg-visual-element.ts +114 -0
- package/src/render/dom/types.ts +32 -0
- package/src/render/dom/use-render.ts +11 -0
- package/src/render/dom/utils/UseInitialMotionProps.svelte +26 -0
- package/src/render/dom/utils/batch-layout.ts +77 -0
- package/src/render/dom/utils/camel-to-dash.ts +20 -0
- package/src/render/dom/utils/create-config.ts +33 -0
- package/src/render/dom/utils/css-variables-conversion.ts +121 -0
- package/src/render/dom/utils/filter-props.ts +55 -0
- package/src/render/dom/utils/is-css-variable.ts +18 -0
- package/src/render/dom/utils/is-svg-component.ts +41 -0
- package/src/render/dom/utils/parse-dom-variant.ts +26 -0
- package/src/render/dom/utils/unit-conversion.ts +258 -0
- package/src/render/dom/utils/use-html-props.ts +2 -0
- package/src/render/dom/utils/use-svg-props.ts +1 -0
- package/src/render/dom/value-types/animatable-none.ts +24 -0
- package/src/render/dom/value-types/defaults.ts +30 -0
- package/src/render/dom/value-types/dimensions.ts +27 -0
- package/src/render/dom/value-types/find.ts +31 -0
- package/src/render/dom/value-types/get-as-type.ts +21 -0
- package/src/render/dom/value-types/number.ts +83 -0
- package/src/render/dom/value-types/test.ts +17 -0
- package/src/render/dom/value-types/type-auto.ts +21 -0
- package/src/render/dom/value-types/type-int.ts +23 -0
- package/src/render/dom/value-types/types.ts +8 -0
- package/src/render/html/UseHTMLProps.svelte +33 -0
- package/src/render/html/UseInitialMotionValues.svelte +27 -0
- package/src/render/html/UseStyle.svelte +47 -0
- package/src/render/html/config-motion.ts +23 -0
- package/src/render/html/supported-elements.ts +10 -0
- package/src/render/html/types.ts +64 -0
- package/src/render/html/use-props.ts +14 -0
- package/src/render/html/utils/build-projection-transform.ts +53 -0
- package/src/render/html/utils/build-styles.ts +121 -0
- package/src/render/html/utils/build-transform.ts +79 -0
- package/src/render/html/utils/create-render-state.ts +18 -0
- package/src/render/html/utils/render.ts +22 -0
- package/src/render/html/utils/scrape-motion-values.ts +26 -0
- package/src/render/html/utils/transform.ts +51 -0
- package/src/render/html/visual-element.ts +129 -0
- package/src/render/index.ts +703 -0
- package/src/render/svg/UseSVGProps.svelte +34 -0
- package/src/render/svg/config-motion.ts +51 -0
- package/src/render/svg/lowercase-elements.ts +35 -0
- package/src/render/svg/supported-elements.ts +10 -0
- package/src/render/svg/types.ts +51 -0
- package/src/render/svg/use-props.ts +14 -0
- package/src/render/svg/utils/build-attrs.ts +58 -0
- package/src/render/svg/utils/camel-case-attrs.ts +27 -0
- package/src/render/svg/utils/create-render-state.ts +17 -0
- package/src/render/svg/utils/path.ts +49 -0
- package/src/render/svg/utils/render.ts +22 -0
- package/src/render/svg/utils/scrape-motion-values.ts +26 -0
- package/src/render/svg/utils/transform-origin.ts +30 -0
- package/src/render/svg/visual-element.ts +44 -0
- package/src/render/types.ts +148 -0
- package/src/render/utils/animation-state.ts +375 -0
- package/src/render/utils/animation.ts +167 -0
- package/src/render/utils/compare-by-depth.ts +18 -0
- package/src/render/utils/flat-tree.ts +35 -0
- package/src/render/utils/is-draggable.ts +17 -0
- package/src/render/utils/lifecycles.ts +172 -0
- package/src/render/utils/motion-values.ts +59 -0
- package/src/render/utils/projection.ts +38 -0
- package/src/render/utils/setters.ts +910 -0
- package/src/render/utils/state.ts +113 -0
- package/src/render/utils/types.ts +12 -0
- package/src/render/utils/variants.ts +76 -0
- package/src/types/geometry.ts +91 -0
- package/src/types.ts +1088 -0
- package/src/utils/UseUnmountEffect.svelte +11 -0
- package/src/utils/array.ts +18 -0
- package/src/utils/each-axis.ts +15 -0
- package/src/utils/errors.ts +22 -0
- package/src/utils/fix-process-env.ts +22 -0
- package/src/utils/geometry/delta-apply.ts +162 -0
- package/src/utils/geometry/delta-calc.ts +89 -0
- package/src/utils/geometry/index.ts +83 -0
- package/src/utils/is-browser.ts +12 -0
- package/src/utils/is-numerical-string.ts +15 -0
- package/src/utils/is-ref-object.ts +16 -0
- package/src/utils/noop.ts +15 -0
- package/src/utils/resolve-value.ts +23 -0
- package/src/utils/shallow-compare.ts +23 -0
- package/src/utils/subscription-manager.ts +49 -0
- package/src/utils/time-conversion.ts +18 -0
- package/src/utils/transform.ts +120 -0
- package/src/utils/use-constant.ts +23 -0
- package/src/utils/use-cycle.ts +78 -0
- package/src/utils/use-force-update.ts +7 -0
- package/src/utils/use-isomorphic-effect.ts +8 -0
- package/src/utils/use-reduced-motion.ts +70 -0
- package/src/utils/use-unmount-effect.ts +8 -0
- package/src/value/index.ts +409 -0
- package/src/value/scroll/use-element-scroll.ts +73 -0
- package/src/value/scroll/use-viewport-scroll.ts +81 -0
- package/src/value/scroll/utils.ts +76 -0
- package/src/value/use-combine-values.ts +53 -0
- package/src/value/use-motion-template.ts +57 -0
- package/src/value/use-motion-value.ts +27 -0
- package/src/value/use-spring.ts +84 -0
- package/src/value/use-transform.ts +216 -0
- package/src/value/use-velocity.ts +44 -0
- package/src/value/utils/is-motion-value.ts +15 -0
- package/src/value/utils/resolve-motion-value.ts +29 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { copyRawValuesOnly } from "../html/use-props.js";
|
|
6
|
+
import { buildSVGAttrs } from "./utils/build-attrs.js";
|
|
7
|
+
import { createSvgRenderState } from "./utils/create-render-state.js";
|
|
8
|
+
|
|
9
|
+
export let visualState, props;
|
|
10
|
+
let memo = () => {
|
|
11
|
+
const state = createSvgRenderState();
|
|
12
|
+
buildSVGAttrs(
|
|
13
|
+
state,
|
|
14
|
+
visualState,
|
|
15
|
+
undefined,
|
|
16
|
+
undefined,
|
|
17
|
+
{ enableHardwareAcceleration: false },
|
|
18
|
+
props.transformTemplate
|
|
19
|
+
);
|
|
20
|
+
return {
|
|
21
|
+
...state.attrs,
|
|
22
|
+
style: { ...state.style },
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
$: visualProps = memo(visualState);
|
|
26
|
+
|
|
27
|
+
$: if (props.style) {
|
|
28
|
+
const rawStyles = {};
|
|
29
|
+
copyRawValuesOnly(rawStyles, props.style, props);
|
|
30
|
+
visualProps.style = { ...rawStyles, ...visualProps.style };
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<slot {visualProps} />
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { MotionComponentConfig } from "../../motion";
|
|
6
|
+
import type { SVGRenderState } from "./types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import { buildSVGAttrs } from './utils/build-attrs.js';
|
|
13
|
+
import { createSvgRenderState } from './utils/create-render-state.js';
|
|
14
|
+
import { renderSVG } from './utils/render.js';
|
|
15
|
+
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
|
|
16
|
+
|
|
17
|
+
var svgMotionConfig = {
|
|
18
|
+
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
19
|
+
createRenderState: createSvgRenderState,
|
|
20
|
+
onMount: function (props, instance, _a) {
|
|
21
|
+
var renderState = _a.renderState, latestValues = _a.latestValues;
|
|
22
|
+
try {
|
|
23
|
+
renderState.dimensions =
|
|
24
|
+
typeof instance.getBBox ===
|
|
25
|
+
"function"
|
|
26
|
+
? instance.getBBox()
|
|
27
|
+
: instance.getBoundingClientRect();
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
// Most likely trying to measure an unrendered element under Firefox
|
|
31
|
+
renderState.dimensions = {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
width: 0,
|
|
35
|
+
height: 0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (isPath(instance)) {
|
|
39
|
+
renderState.totalPathLength = instance.getTotalLength();
|
|
40
|
+
}
|
|
41
|
+
buildSVGAttrs(renderState, latestValues, undefined, undefined, { enableHardwareAcceleration: false }, props.transformTemplate);
|
|
42
|
+
// TODO: Replace with direct assignment
|
|
43
|
+
renderSVG(instance, renderState);
|
|
44
|
+
},
|
|
45
|
+
} satisfies Partial<MotionComponentConfig<SVGElement, SVGRenderState>>
|
|
46
|
+
function isPath(element) {
|
|
47
|
+
return element.tagName === "path";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { svgMotionConfig };
|
|
51
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.0.3,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* We keep these listed seperately as we use the lowercase tag names as part
|
|
7
|
+
* of the runtime bundle to detect SVG components
|
|
8
|
+
*/
|
|
9
|
+
export const lowercaseSVGElements = [
|
|
10
|
+
"animate",
|
|
11
|
+
"circle",
|
|
12
|
+
"defs",
|
|
13
|
+
"desc",
|
|
14
|
+
"ellipse",
|
|
15
|
+
"g",
|
|
16
|
+
"image",
|
|
17
|
+
"line",
|
|
18
|
+
"filter",
|
|
19
|
+
"marker",
|
|
20
|
+
"mask",
|
|
21
|
+
"metadata",
|
|
22
|
+
"path",
|
|
23
|
+
"pattern",
|
|
24
|
+
"polygon",
|
|
25
|
+
"polyline",
|
|
26
|
+
"rect",
|
|
27
|
+
"stop",
|
|
28
|
+
"svg",
|
|
29
|
+
"switch",
|
|
30
|
+
"symbol",
|
|
31
|
+
"text",
|
|
32
|
+
"tspan",
|
|
33
|
+
"use",
|
|
34
|
+
"view",
|
|
35
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
type UnionStringArray<T extends Readonly<string[]>> = T[number];
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const svgElements = ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"] as const;
|
|
10
|
+
export type SVGElements = UnionStringArray<typeof svgElements>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { SVGAttributes } from "react";
|
|
6
|
+
import type { MakeMotion, MotionProps } from "../../motion/types";
|
|
7
|
+
import type { ForwardRefComponent, HTMLRenderState } from "../html/types";
|
|
8
|
+
import type { ResolvedValues } from "../types";
|
|
9
|
+
import type { SVGElements } from "./supported-elements";
|
|
10
|
+
export interface SVGRenderState extends HTMLRenderState {
|
|
11
|
+
/**
|
|
12
|
+
* Measured dimensions of the SVG element to be used to calculate a transform-origin.
|
|
13
|
+
*/
|
|
14
|
+
dimensions?: SVGDimensions;
|
|
15
|
+
/**
|
|
16
|
+
* A mutable record of attributes we want to apply directly to the rendered Element
|
|
17
|
+
* every frame. We use a mutable data structure to reduce GC during animations.
|
|
18
|
+
*/
|
|
19
|
+
attrs: ResolvedValues;
|
|
20
|
+
/**
|
|
21
|
+
* Measured path length if this is a SVGPathElement
|
|
22
|
+
*/
|
|
23
|
+
totalPathLength?: number;
|
|
24
|
+
}
|
|
25
|
+
export type SVGDimensions = {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
interface SVGAttributesWithoutMotionProps<T> extends Pick<SVGAttributes<T>, Exclude<keyof SVGAttributes<T>, keyof MotionProps>> {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Blanket-accept any SVG attribute as a `MotionValue`
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export type SVGAttributesAsMotionValues<T> = MakeMotion<SVGAttributesWithoutMotionProps<T>>;
|
|
38
|
+
type UnwrapSVGFactoryElement<F> = F extends React.SVGProps<infer P> ? P : never;
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface SVGMotionProps<T> extends SVGAttributesAsMotionValues<T>, MotionProps {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Motion-optimised versions of React's SVG components.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export type SVGMotionComponents = {
|
|
50
|
+
[K in SVGElements]: ForwardRefComponent<UnwrapSVGFactoryElement<JSX.IntrinsicElements[K]>, SVGMotionProps<UnwrapSVGFactoryElement<JSX.IntrinsicElements[K]>>>;
|
|
51
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { MotionProps } from "../../motion/types";
|
|
6
|
+
import type { ResolvedValues } from "../types";
|
|
7
|
+
export type useSVGProps = (props: MotionProps, visualState: ResolvedValues) => {
|
|
8
|
+
style: {
|
|
9
|
+
[x: string]: string | number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { default as UseSVGProps } from './UseSVGProps.svelte';
|
|
14
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { DOMVisualElementOptions } from "../../dom/types";
|
|
6
|
+
import type { ResolvedValues } from "../../types";
|
|
7
|
+
import type { MotionProps } from "../../../motion/types";
|
|
8
|
+
import type { LayoutState, TargetProjection } from "../../utils/state";
|
|
9
|
+
import type { SVGRenderState } from "../types";
|
|
10
|
+
import type { BuildProjectionTransform, BuildProjectionTransformOrigin } from "../../html/utils/build-projection-transform";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
based on framer-motion@4.0.3,
|
|
15
|
+
Copyright (c) 2018 Framer B.V.
|
|
16
|
+
*/
|
|
17
|
+
import { __rest } from 'tslib';
|
|
18
|
+
import { buildHTMLStyles } from '../../html/utils/build-styles.js';
|
|
19
|
+
import { calcSVGTransformOrigin } from './transform-origin.js';
|
|
20
|
+
import { buildSVGPath } from './path.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Build SVG visual attrbutes, like cx and style.transform
|
|
24
|
+
*/
|
|
25
|
+
function buildSVGAttrs(state: SVGRenderState, { attrX, attrY, originX, originY, pathLength, pathSpacing, pathOffset, ...latest }: ResolvedValues, projection: TargetProjection | undefined, layoutState: LayoutState | undefined, options: DOMVisualElementOptions, transformTemplate?: MotionProps["transformTemplate"], buildProjectionTransform?: BuildProjectionTransform, buildProjectionTransformOrigin?: BuildProjectionTransformOrigin) {
|
|
26
|
+
// var attrX = _a.attrX, attrY = _a.attrY, originX = _a.originX, originY = _a.originY, pathLength = _a.pathLength, _b = _a.pathSpacing, pathSpacing = _b === void 0 ? 1 : _b, _c = _a.pathOffset, pathOffset = _c === void 0 ? 0 : _c,
|
|
27
|
+
// // This is object creation, which we try to avoid per-frame.
|
|
28
|
+
// latest = __rest(_a, ["attrX", "attrY", "originX", "originY", "pathLength", "pathSpacing", "pathOffset"]);
|
|
29
|
+
buildHTMLStyles(state, latest, projection, layoutState, options, transformTemplate, buildProjectionTransform, buildProjectionTransformOrigin);
|
|
30
|
+
state.attrs = state.style;
|
|
31
|
+
state.style = {};
|
|
32
|
+
var attrs = state.attrs, style = state.style, dimensions = state.dimensions, totalPathLength = state.totalPathLength;
|
|
33
|
+
/**
|
|
34
|
+
* However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
|
|
35
|
+
* and copy it into style.
|
|
36
|
+
*/
|
|
37
|
+
if (attrs.transform) {
|
|
38
|
+
if (dimensions)
|
|
39
|
+
style.transform = attrs.transform;
|
|
40
|
+
delete attrs.transform;
|
|
41
|
+
}
|
|
42
|
+
// Parse transformOrigin
|
|
43
|
+
if (dimensions &&
|
|
44
|
+
(originX !== undefined || originY !== undefined || style.transform)) {
|
|
45
|
+
style.transformOrigin = calcSVGTransformOrigin(dimensions, originX !== undefined ? originX : 0.5, originY !== undefined ? originY : 0.5);
|
|
46
|
+
}
|
|
47
|
+
// Treat x/y not as shortcuts but as actual attributes
|
|
48
|
+
if (attrX !== undefined)
|
|
49
|
+
attrs.x = attrX;
|
|
50
|
+
if (attrY !== undefined)
|
|
51
|
+
attrs.y = attrY;
|
|
52
|
+
// Build SVG path if one has been measured
|
|
53
|
+
if (totalPathLength !== undefined && pathLength !== undefined) {
|
|
54
|
+
buildSVGPath(attrs, totalPathLength, pathLength, pathSpacing, pathOffset, false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { buildSVGAttrs };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.0.3,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A set of attribute names that are always read/written as camel case.
|
|
7
|
+
*/
|
|
8
|
+
export const camelCaseAttributes = new Set([
|
|
9
|
+
"baseFrequency",
|
|
10
|
+
"diffuseConstant",
|
|
11
|
+
"kernelMatrix",
|
|
12
|
+
"kernelUnitLength",
|
|
13
|
+
"keySplines",
|
|
14
|
+
"keyTimes",
|
|
15
|
+
"limitingConeAngle",
|
|
16
|
+
"markerHeight",
|
|
17
|
+
"markerWidth",
|
|
18
|
+
"numOctaves",
|
|
19
|
+
"targetX",
|
|
20
|
+
"targetY",
|
|
21
|
+
"surfaceScale",
|
|
22
|
+
"specularConstant",
|
|
23
|
+
"specularExponent",
|
|
24
|
+
"stdDeviation",
|
|
25
|
+
"tableValues",
|
|
26
|
+
"viewBox",
|
|
27
|
+
]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { SVGRenderState } from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import { __assign } from 'tslib';
|
|
12
|
+
import { createHtmlRenderState } from '../../html/utils/create-render-state.js';
|
|
13
|
+
|
|
14
|
+
var createSvgRenderState = function () { return (__assign(__assign({}, createHtmlRenderState()), { attrs: {} })) satisfies SVGRenderState; };
|
|
15
|
+
|
|
16
|
+
export { createSvgRenderState };
|
|
17
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolvedValues } from "../../types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import {fixed} from '../../../utils/fix-process-env';
|
|
13
|
+
import { px } from 'style-value-types';
|
|
14
|
+
|
|
15
|
+
// Convert a progress 0-1 to a pixels value based on the provided length
|
|
16
|
+
var progressToPixels = function (progress, length) {
|
|
17
|
+
return px.transform(progress * length);
|
|
18
|
+
};
|
|
19
|
+
var dashKeys = {
|
|
20
|
+
offset: "stroke-dashoffset",
|
|
21
|
+
array: "stroke-dasharray",
|
|
22
|
+
};
|
|
23
|
+
var camelKeys = {
|
|
24
|
+
offset: "strokeDashoffset",
|
|
25
|
+
array: "strokeDasharray",
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Build SVG path properties. Uses the path's measured length to convert
|
|
29
|
+
* our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset
|
|
30
|
+
* and stroke-dasharray attributes.
|
|
31
|
+
*
|
|
32
|
+
* This function is mutative to reduce per-frame GC.
|
|
33
|
+
*/
|
|
34
|
+
function buildSVGPath(attrs: ResolvedValues, totalLength: number, length: number, spacing?: number, offset?: number, useDashCase?: boolean) {
|
|
35
|
+
if (spacing === void 0) { spacing = 1; }
|
|
36
|
+
if (offset === void 0) { offset = 0; }
|
|
37
|
+
if (useDashCase === void 0) { useDashCase = true; }
|
|
38
|
+
// We use dash case when setting attributes directly to the DOM node and camel case
|
|
39
|
+
// when defining props on a React component.
|
|
40
|
+
var keys = useDashCase ? dashKeys : camelKeys;
|
|
41
|
+
// Build the dash offset
|
|
42
|
+
attrs[keys.offset] = progressToPixels(-offset, totalLength);
|
|
43
|
+
// Build the dash array
|
|
44
|
+
var pathLength = progressToPixels(length, totalLength);
|
|
45
|
+
var pathSpacing = progressToPixels(spacing, totalLength);
|
|
46
|
+
attrs[keys.array] = pathLength + " " + pathSpacing;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { buildSVGPath };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { SVGRenderState } from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import { camelToDash } from '../../dom/utils/camel-to-dash.js';
|
|
12
|
+
import { renderHTML } from '../../html/utils/render.js';
|
|
13
|
+
import { camelCaseAttributes } from './camel-case-attrs.js';
|
|
14
|
+
|
|
15
|
+
function renderSVG(element: SVGElement, renderState: SVGRenderState) {
|
|
16
|
+
renderHTML(element, renderState);
|
|
17
|
+
for (var key in renderState.attrs) {
|
|
18
|
+
element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { renderSVG };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { MotionProps } from "../../../motion/types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import { isMotionValue } from '../../../value/utils/is-motion-value.js';
|
|
13
|
+
import { scrapeMotionValuesFromProps as scrapeMotionValuesFromProps$1 } from '../../html/utils/scrape-motion-values.js';
|
|
14
|
+
|
|
15
|
+
function scrapeMotionValuesFromProps(props: MotionProps) {
|
|
16
|
+
var newValues = scrapeMotionValuesFromProps$1(props);
|
|
17
|
+
for (var key in props) {
|
|
18
|
+
if (isMotionValue(props[key])) {
|
|
19
|
+
var targetKey = key === "x" || key === "y" ? "attr" + key.toUpperCase() : key;
|
|
20
|
+
newValues[targetKey] = props[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return newValues;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { scrapeMotionValuesFromProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { SVGDimensions } from "../types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import {fixed} from '../../../utils/fix-process-env';
|
|
13
|
+
import { px } from 'style-value-types';
|
|
14
|
+
|
|
15
|
+
function calcOrigin(origin, offset, size) {
|
|
16
|
+
return typeof origin === "string"
|
|
17
|
+
? origin
|
|
18
|
+
: px.transform(offset + size * origin);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The SVG transform origin defaults are different to CSS and is less intuitive,
|
|
22
|
+
* so we use the measured dimensions of the SVG to reconcile these.
|
|
23
|
+
*/
|
|
24
|
+
function calcSVGTransformOrigin(dimensions: SVGDimensions, originX: number | string, originY: number | string) {
|
|
25
|
+
var pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
|
|
26
|
+
var pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
|
|
27
|
+
return pxOriginX + " " + pxOriginY;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { calcSVGTransformOrigin };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
// export declare const svgVisualElement: ({ parent, props, presenceId, blockInitialAnimation, visualState, }: import("../types").VisualElementOptions<SVGElement, any>, options?: DOMVisualElementOptions) => import("../types").VisualElement<SVGElement, any>;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import { __assign } from 'tslib';
|
|
13
|
+
import { camelToDash } from '../dom/utils/camel-to-dash.js';
|
|
14
|
+
import { getDefaultValueType } from '../dom/value-types/defaults.js';
|
|
15
|
+
import { buildLayoutProjectionTransform, buildLayoutProjectionTransformOrigin } from '../html/utils/build-projection-transform.js';
|
|
16
|
+
import { isTransformProp } from '../html/utils/transform.js';
|
|
17
|
+
import { htmlConfig } from '../html/visual-element.js';
|
|
18
|
+
import { visualElement } from '../index.js';
|
|
19
|
+
import { buildSVGAttrs } from './utils/build-attrs.js';
|
|
20
|
+
import { camelCaseAttributes } from './utils/camel-case-attrs.js';
|
|
21
|
+
import { renderSVG } from './utils/render.js';
|
|
22
|
+
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.js';
|
|
23
|
+
|
|
24
|
+
var svgVisualElement = visualElement<SVGElement>(__assign(__assign({}, htmlConfig), { getBaseTarget: function (props, key) {
|
|
25
|
+
return props[key];
|
|
26
|
+
},
|
|
27
|
+
readValueFromInstance: function (domElement, key) {
|
|
28
|
+
var _a;
|
|
29
|
+
if (isTransformProp(key)) {
|
|
30
|
+
return ((_a = getDefaultValueType(key)) === null || _a === void 0 ? void 0 : _a.default) || 0;
|
|
31
|
+
}
|
|
32
|
+
key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
|
|
33
|
+
return domElement.getAttribute(key);
|
|
34
|
+
},
|
|
35
|
+
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
36
|
+
build: function (_element, renderState, latestValues, projection, layoutState, options, props) {
|
|
37
|
+
var isProjectionTranform = projection.isEnabled && layoutState.isHydrated;
|
|
38
|
+
buildSVGAttrs(renderState, latestValues, projection, layoutState, options, props.transformTemplate, isProjectionTranform ? buildLayoutProjectionTransform : undefined, isProjectionTranform
|
|
39
|
+
? buildLayoutProjectionTransformOrigin
|
|
40
|
+
: undefined);
|
|
41
|
+
}, render: renderSVG }));
|
|
42
|
+
|
|
43
|
+
export { svgVisualElement };
|
|
44
|
+
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { Component } from "svelte";
|
|
6
|
+
import { startAnimation } from "../animation/utils/transitions";
|
|
7
|
+
import { Presence, type SharedLayoutAnimationConfig } from "../components/AnimateSharedLayout/types";
|
|
8
|
+
import type { Crossfader } from "../components/AnimateSharedLayout/utils/crossfader";
|
|
9
|
+
import type { MotionProps } from "../motion/types";
|
|
10
|
+
import type { VisualState } from "../motion/utils/use-visual-state";
|
|
11
|
+
import type { TargetAndTransition, Transition, Variant } from "../types";
|
|
12
|
+
import type { AxisBox2D, Point2D } from "../types/geometry";
|
|
13
|
+
import { MotionValue } from "../value";
|
|
14
|
+
import type { AnimationState } from "./utils/animation-state";
|
|
15
|
+
import { FlatTree } from "./utils/flat-tree";
|
|
16
|
+
import type { LifecycleManager } from "./utils/lifecycles";
|
|
17
|
+
import type { LayoutState, TargetProjection } from "./utils/state";
|
|
18
|
+
|
|
19
|
+
export interface MotionPoint {
|
|
20
|
+
x: MotionValue<number>;
|
|
21
|
+
y: MotionValue<number>;
|
|
22
|
+
}
|
|
23
|
+
export interface VisualElement<Instance = any, RenderState = any> extends LifecycleManager {
|
|
24
|
+
treeType: string;
|
|
25
|
+
depth: number;
|
|
26
|
+
parent?: VisualElement;
|
|
27
|
+
children: Set<VisualElement>;
|
|
28
|
+
variantChildren?: Set<VisualElement>;
|
|
29
|
+
current: Instance | null;
|
|
30
|
+
layoutTree: FlatTree;
|
|
31
|
+
manuallyAnimateOnMount: boolean;
|
|
32
|
+
blockInitialAnimation?: boolean;
|
|
33
|
+
presenceId: number | undefined;
|
|
34
|
+
projection: TargetProjection;
|
|
35
|
+
isProjectionReady: () => boolean;
|
|
36
|
+
isMounted(): boolean;
|
|
37
|
+
mount(instance: Instance): void;
|
|
38
|
+
unmount(): void;
|
|
39
|
+
isStatic?: boolean;
|
|
40
|
+
getInstance(): Instance | null;
|
|
41
|
+
path: VisualElement[];
|
|
42
|
+
sortNodePosition(element: VisualElement): number;
|
|
43
|
+
addVariantChild(child: VisualElement): undefined | (() => void);
|
|
44
|
+
getClosestVariantNode(): VisualElement | undefined;
|
|
45
|
+
setCrossfader(crossfader: Crossfader): void;
|
|
46
|
+
layoutSafeToRemove?: () => void;
|
|
47
|
+
animateMotionValue?: typeof startAnimation;
|
|
48
|
+
/**
|
|
49
|
+
* Visibility
|
|
50
|
+
*/
|
|
51
|
+
isVisible?: boolean;
|
|
52
|
+
setVisibility(visibility: boolean): void;
|
|
53
|
+
hasValue(key: string): boolean;
|
|
54
|
+
addValue(key: string, value: MotionValue<any>): void;
|
|
55
|
+
removeValue(key: string): void;
|
|
56
|
+
getValue(key: string): undefined | MotionValue;
|
|
57
|
+
getValue(key: string, defaultValue: string | number): MotionValue;
|
|
58
|
+
getValue(key: string, defaultValue?: string | number): undefined | MotionValue;
|
|
59
|
+
forEachValue(callback: (value: MotionValue, key: string) => void): void;
|
|
60
|
+
readValue(key: string): string | number | undefined | null;
|
|
61
|
+
setBaseTarget(key: string, value: string | number | null): void;
|
|
62
|
+
getBaseTarget(key: string): number | string | undefined | null;
|
|
63
|
+
getStaticValue(key: string): number | string | undefined;
|
|
64
|
+
setStaticValue(key: string, value: number | string): void;
|
|
65
|
+
getLatestValues(): ResolvedValues;
|
|
66
|
+
scheduleRender(): void;
|
|
67
|
+
setProps(props: MotionProps): void;
|
|
68
|
+
getProps(): MotionProps;
|
|
69
|
+
getVariant(name: string): Variant | undefined;
|
|
70
|
+
getDefaultTransition(): Transition | undefined;
|
|
71
|
+
getVariantContext(startAtParent?: boolean): undefined | {
|
|
72
|
+
initial?: string | string[];
|
|
73
|
+
animate?: string | string[];
|
|
74
|
+
exit?: string | string[];
|
|
75
|
+
whileHover?: string | string[];
|
|
76
|
+
whileDrag?: string | string[];
|
|
77
|
+
whileFocus?: string | string[];
|
|
78
|
+
whileTap?: string | string[];
|
|
79
|
+
};
|
|
80
|
+
build(): RenderState;
|
|
81
|
+
syncRender(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Layout projection - perhaps a candidate for lazy-loading
|
|
84
|
+
* or an external interface. Move into Projection?
|
|
85
|
+
*/
|
|
86
|
+
enableLayoutProjection(): void;
|
|
87
|
+
lockProjectionTarget(): void;
|
|
88
|
+
unlockProjectionTarget(): void;
|
|
89
|
+
rebaseProjectionTarget(force?: boolean, sourceBox?: AxisBox2D): void;
|
|
90
|
+
measureViewportBox(withTransform?: boolean): AxisBox2D;
|
|
91
|
+
getLayoutState: () => LayoutState;
|
|
92
|
+
getProjectionParent: () => VisualElement | false;
|
|
93
|
+
getProjectionAnimationProgress(): MotionPoint;
|
|
94
|
+
setProjectionTargetAxis(axis: "x" | "y", min: number, max: number, isRelative?: boolean): void;
|
|
95
|
+
startLayoutAnimation(axis: "x" | "y", transition: Transition, isRelative: boolean): Promise<any>;
|
|
96
|
+
stopLayoutAnimation(): void;
|
|
97
|
+
updateLayoutProjection(): void;
|
|
98
|
+
updateTreeLayoutProjection(): void;
|
|
99
|
+
resolveRelativeTargetBox(): void;
|
|
100
|
+
makeTargetAnimatable(target: TargetAndTransition, isLive?: boolean): TargetAndTransition;
|
|
101
|
+
scheduleUpdateLayoutProjection(): void;
|
|
102
|
+
notifyLayoutReady(config?: SharedLayoutAnimationConfig): void;
|
|
103
|
+
pointTo(element: VisualElement): void;
|
|
104
|
+
resetTransform(): void;
|
|
105
|
+
restoreTransform(): void;
|
|
106
|
+
shouldResetTransform(): boolean;
|
|
107
|
+
isPresent: boolean;
|
|
108
|
+
presence: Presence;
|
|
109
|
+
isPresenceRoot?: boolean;
|
|
110
|
+
prevDragCursor?: Point2D;
|
|
111
|
+
prevViewportBox?: AxisBox2D;
|
|
112
|
+
getLayoutId(): string | undefined;
|
|
113
|
+
animationState?: AnimationState;
|
|
114
|
+
}
|
|
115
|
+
export interface VisualElementConfig<Instance, RenderState, Options> {
|
|
116
|
+
treeType?: string;
|
|
117
|
+
getBaseTarget?(props: MotionProps, key: string): string | number | undefined | MotionValue;
|
|
118
|
+
build(visualElement: VisualElement<Instance>, renderState: RenderState, latestValues: ResolvedValues, projection: TargetProjection, layoutState: LayoutState, options: Options, props: MotionProps): void;
|
|
119
|
+
sortNodePosition?: (a: Instance, b: Instance) => number;
|
|
120
|
+
makeTargetAnimatable(element: VisualElement<Instance>, target: TargetAndTransition, props: MotionProps, isLive: boolean): TargetAndTransition;
|
|
121
|
+
measureViewportBox(instance: Instance, options: Options): AxisBox2D;
|
|
122
|
+
readValueFromInstance(instance: Instance, key: string, options: Options): string | number | null | undefined;
|
|
123
|
+
resetTransform(element: VisualElement<Instance>, instance: Instance, props: MotionProps): void;
|
|
124
|
+
restoreTransform(instance: Instance, renderState: RenderState): void;
|
|
125
|
+
render(instance: Instance, renderState: RenderState): void;
|
|
126
|
+
removeValueFromRenderState(key: string, renderState: RenderState): void;
|
|
127
|
+
scrapeMotionValuesFromProps: ScrapeMotionValuesFromProps;
|
|
128
|
+
}
|
|
129
|
+
export type ScrapeMotionValuesFromProps = (props: MotionProps) => {
|
|
130
|
+
[key: string]: MotionValue | string | number;
|
|
131
|
+
};
|
|
132
|
+
export type UseRenderState<RenderState = any> = () => RenderState;
|
|
133
|
+
export type VisualElementOptions<Instance, RenderState = any> = {
|
|
134
|
+
visualState: VisualState<Instance, RenderState>;
|
|
135
|
+
parent?: VisualElement<unknown>;
|
|
136
|
+
variantParent?: VisualElement<unknown>;
|
|
137
|
+
snapshot?: ResolvedValues;
|
|
138
|
+
presenceId?: number | undefined;
|
|
139
|
+
props: MotionProps;
|
|
140
|
+
blockInitialAnimation?: boolean;
|
|
141
|
+
};
|
|
142
|
+
export type CreateVisualElement<Instance> = (Component: string | Component, options?: VisualElementOptions<Instance>) => VisualElement<Instance>;
|
|
143
|
+
/**
|
|
144
|
+
* A generic set of string/number values
|
|
145
|
+
*/
|
|
146
|
+
export interface ResolvedValues {
|
|
147
|
+
[key: string]: string | number;
|
|
148
|
+
}
|