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,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { RefObject } from "react";
|
|
6
|
+
import type { Point2D } from "../types/geometry";
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export interface EventInfo {
|
|
10
|
+
point: Point2D;
|
|
11
|
+
}
|
|
12
|
+
export type EventHandler = (event: MouseEvent | TouchEvent | PointerEvent, info: EventInfo) => void;
|
|
13
|
+
export type ListenerControls = [() => void, () => void];
|
|
14
|
+
export type TargetOrRef = EventTarget | RefObject<EventTarget>;
|
|
15
|
+
export type TargetBasedReturnType<Target> = Target extends EventTarget ? ListenerControls : undefined;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { VisualElement } from "../index.js";
|
|
6
|
+
export interface UseDomEventProps {
|
|
7
|
+
/**
|
|
8
|
+
* Ref object that's been provided to the element you want to bind the listener to.
|
|
9
|
+
*/
|
|
10
|
+
ref: {current:Node} | VisualElement<EventTarget>,
|
|
11
|
+
/**
|
|
12
|
+
* Name of the event you want listen for.
|
|
13
|
+
*/
|
|
14
|
+
eventName: string,
|
|
15
|
+
/**
|
|
16
|
+
* Function to fire when receiving the event.
|
|
17
|
+
*/
|
|
18
|
+
handler?: EventListener,
|
|
19
|
+
/**
|
|
20
|
+
* Options to pass to `Event.addEventListener`.
|
|
21
|
+
*/
|
|
22
|
+
options?: AddEventListenerOptions
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Attaches an event listener directly to the provided DOM element.
|
|
26
|
+
*
|
|
27
|
+
* Bypassing Sveltes's event system can be desirable, for instance when attaching non-passive
|
|
28
|
+
* event handlers.
|
|
29
|
+
*
|
|
30
|
+
* ```jsx
|
|
31
|
+
* <script>
|
|
32
|
+
* import { useDomEvent } from 'svelte-motion'
|
|
33
|
+
* let ref;
|
|
34
|
+
* </script>
|
|
35
|
+
*
|
|
36
|
+
* <UseDomEvent ref={{current:ref}} eventName="wheel" handler={onWheel} options={{passive: false}/>
|
|
37
|
+
* <div bind:this={ref}/>
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
|
|
41
|
+
* @param eventName - Name of the event you want listen for.
|
|
42
|
+
* @param handler - Function to fire when receiving the event.
|
|
43
|
+
* @param options - Options to pass to `Event.addEventListener`.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export { default as UseDomEvent, addDomEvent } from './UseDomEvent.svelte';
|
|
48
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { RefObject } from "react";
|
|
6
|
+
import type { EventListenerWithPointInfo } from "./event-info";
|
|
7
|
+
export type usePointerEvent = (ref: RefObject<Element>, eventName: string, handler?: EventListenerWithPointInfo | undefined, options?: AddEventListenerOptions) => void;
|
|
8
|
+
|
|
9
|
+
export interface UsePointerEventProps {
|
|
10
|
+
/**
|
|
11
|
+
* Ref object that's been provided to the element you want to bind the listener to.
|
|
12
|
+
*/
|
|
13
|
+
ref: RefObject<Element>,
|
|
14
|
+
/**
|
|
15
|
+
* Name of the event you want listen for.
|
|
16
|
+
*/
|
|
17
|
+
eventName: string,
|
|
18
|
+
/**
|
|
19
|
+
* Function to fire when receiving the event.
|
|
20
|
+
*/
|
|
21
|
+
handler?: EventListener | undefined,
|
|
22
|
+
/**
|
|
23
|
+
* Options to pass to `Event.addEventListener`.
|
|
24
|
+
*/
|
|
25
|
+
options?: AddEventListenerOptions
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { default as UsePointerEvent, addPointerEvent } from './UsePointerEvent.svelte';
|
|
29
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { isBrowser } from '../utils/is-browser.js';
|
|
13
|
+
|
|
14
|
+
// We check for event support via functions in case they've been mocked by a testing suite.
|
|
15
|
+
var supportsPointerEvents = function () {
|
|
16
|
+
return isBrowser && window.onpointerdown === null;
|
|
17
|
+
};
|
|
18
|
+
var supportsTouchEvents = function () {
|
|
19
|
+
return isBrowser && window.ontouchstart === null;
|
|
20
|
+
};
|
|
21
|
+
var supportsMouseEvents = function () {
|
|
22
|
+
return isBrowser && window.onmousedown === null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { supportsMouseEvents, supportsPointerEvents, supportsTouchEvents };
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { Point2D, TransformPoint2D } from "../types/geometry";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import sync, { cancelSync, getFrameData } from 'framesync';
|
|
12
|
+
import { distance, pipe } from 'popmotion';
|
|
13
|
+
import { __assign } from 'tslib';
|
|
14
|
+
import { extractEventInfo } from '../events/event-info.js';
|
|
15
|
+
import type { EventInfo } from "../events/types";
|
|
16
|
+
import { addPointerEvent } from '../events/use-pointer-event.js';
|
|
17
|
+
import { secondsToMilliseconds } from '../utils/time-conversion.js';
|
|
18
|
+
import { isMouseEvent, isTouchEvent } from './utils/event-type.js';
|
|
19
|
+
|
|
20
|
+
export type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Passed in to pan event handlers like `onPan` the `PanInfo` object contains
|
|
24
|
+
* information about the current state of the tap gesture such as its
|
|
25
|
+
* `point`, `delta`, `offset` and `velocity`.
|
|
26
|
+
*
|
|
27
|
+
* @motion
|
|
28
|
+
*
|
|
29
|
+
* ```jsx
|
|
30
|
+
* <MotionDiv onPan={(event, info) => {
|
|
31
|
+
* console.log(info.point.x, info.point.y)
|
|
32
|
+
* }} />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export interface PanInfo {
|
|
38
|
+
/**
|
|
39
|
+
* Contains `x` and `y` values for the current pan position relative
|
|
40
|
+
* to the device or page.
|
|
41
|
+
*
|
|
42
|
+
* @motion
|
|
43
|
+
*
|
|
44
|
+
* ```jsx
|
|
45
|
+
* function onPan(event, info) {
|
|
46
|
+
* console.log(info.point.x, info.point.y)
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* <MotionDiv onPan={onPan} />
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
point: Point2D;
|
|
55
|
+
/**
|
|
56
|
+
* Contains `x` and `y` values for the distance moved since
|
|
57
|
+
* the last event.
|
|
58
|
+
*
|
|
59
|
+
* @motion
|
|
60
|
+
*
|
|
61
|
+
* ```jsx
|
|
62
|
+
* function onPan(event, info) {
|
|
63
|
+
* console.log(info.delta.x, info.delta.y)
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* <MotionDiv onPan={onPan} />
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
delta: Point2D;
|
|
72
|
+
/**
|
|
73
|
+
* Contains `x` and `y` values for the distance moved from
|
|
74
|
+
* the first pan event.
|
|
75
|
+
*
|
|
76
|
+
* @motion
|
|
77
|
+
*
|
|
78
|
+
* ```jsx
|
|
79
|
+
* function onPan(event, info) {
|
|
80
|
+
* console.log(info.offset.x, info.offset.y)
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* <MotionDiv onPan={onPan} />
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
offset: Point2D;
|
|
89
|
+
/**
|
|
90
|
+
* Contains `x` and `y` values for the current velocity of the pointer, in px/ms.
|
|
91
|
+
*
|
|
92
|
+
* @motion
|
|
93
|
+
*
|
|
94
|
+
* ```jsx
|
|
95
|
+
* function onPan(event, info) {
|
|
96
|
+
* console.log(info.velocity.x, info.velocity.y)
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* <MotionDiv onPan={onPan} />
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
velocity: Point2D;
|
|
105
|
+
}
|
|
106
|
+
export type PanHandler = (event: Event, info: PanInfo) => void;
|
|
107
|
+
interface PanSessionHandlers {
|
|
108
|
+
onSessionStart: PanHandler;
|
|
109
|
+
onStart: PanHandler;
|
|
110
|
+
onMove: PanHandler;
|
|
111
|
+
onEnd: PanHandler;
|
|
112
|
+
onSessionEnd: PanHandler;
|
|
113
|
+
// TODO: future feature
|
|
114
|
+
// resumeAnimation: () => void
|
|
115
|
+
}
|
|
116
|
+
interface PanSessionOptions {
|
|
117
|
+
transformPagePoint?: TransformPoint2D;
|
|
118
|
+
// TODO: future feature
|
|
119
|
+
// contextWindow?: (Window & typeof globalThis) | null
|
|
120
|
+
// dragSnapToOrigin?: boolean
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface TimestampedPoint extends Point2D {
|
|
124
|
+
timestamp: number
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
export class PanSession {
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
private history!: TimestampedPoint[];
|
|
135
|
+
/**
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
private startEvent: PointerEvent | null = null;
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
private lastMoveEvent: PointerEvent | null = null;
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
private lastMoveEventInfo: EventInfo | null = null;
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
private transformPagePoint?: TransformPoint2D
|
|
151
|
+
/**
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
private handlers: Partial<PanSessionHandlers> = {};
|
|
155
|
+
/**
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
private removeListeners!: Function;
|
|
159
|
+
|
|
160
|
+
// TODO: future implementation of newer features
|
|
161
|
+
// /**
|
|
162
|
+
// * For determining if an animation should resume after it is interupted
|
|
163
|
+
// *
|
|
164
|
+
// * @internal
|
|
165
|
+
// */
|
|
166
|
+
// private dragSnapToOrigin: boolean
|
|
167
|
+
|
|
168
|
+
// /**
|
|
169
|
+
// * @internal
|
|
170
|
+
// */
|
|
171
|
+
// private contextWindow: PanSessionOptions["contextWindow"] = window
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
constructor(event: PointerEvent, handlers: Partial<PanSessionHandlers>, { transformPagePoint }: PanSessionOptions = {}) {
|
|
175
|
+
// If we have more than one touch, don't start detecting this gesture
|
|
176
|
+
if (isTouchEvent(event) && event.touches.length > 1)
|
|
177
|
+
return;
|
|
178
|
+
this.handlers = handlers;
|
|
179
|
+
this.transformPagePoint = transformPagePoint;
|
|
180
|
+
var info = extractEventInfo(event);
|
|
181
|
+
var initialInfo = transformPoint(info, this.transformPagePoint);
|
|
182
|
+
var point = initialInfo.point;
|
|
183
|
+
var timestamp = getFrameData().timestamp;
|
|
184
|
+
this.history = [{...point, timestamp}];
|
|
185
|
+
var onSessionStart = handlers.onSessionStart;
|
|
186
|
+
onSessionStart &&
|
|
187
|
+
onSessionStart(event, getPanInfo(initialInfo, this.history));
|
|
188
|
+
this.removeListeners = pipe(addPointerEvent(window, "pointermove", this.handlePointerMove), addPointerEvent(window, "pointerup", this.handlePointerUp), addPointerEvent(window, "pointercancel", this.handlePointerUp));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private updatePoint = () => {
|
|
192
|
+
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
193
|
+
return;
|
|
194
|
+
var info = getPanInfo(this.lastMoveEventInfo, this.history);
|
|
195
|
+
var isPanStarted = this.startEvent !== null;
|
|
196
|
+
// Only start panning if the offset is larger than 3 pixels. If we make it
|
|
197
|
+
// any larger than this we'll want to reset the pointer history
|
|
198
|
+
// on the first update to avoid visual snapping to the cursoe.
|
|
199
|
+
var isDistancePastThreshold = distance(info.offset, { x: 0, y: 0 }) >= 3;
|
|
200
|
+
if (!isPanStarted && !isDistancePastThreshold)
|
|
201
|
+
return;
|
|
202
|
+
var point = info.point;
|
|
203
|
+
var timestamp = getFrameData().timestamp;
|
|
204
|
+
this.history.push(__assign(__assign({}, point), { timestamp: timestamp }));
|
|
205
|
+
var _a = this.handlers, onStart = _a.onStart, onMove = _a.onMove;
|
|
206
|
+
if (!isPanStarted) {
|
|
207
|
+
onStart && onStart(this.lastMoveEvent, info);
|
|
208
|
+
this.startEvent = this.lastMoveEvent;
|
|
209
|
+
}
|
|
210
|
+
onMove && onMove(this.lastMoveEvent, info);
|
|
211
|
+
};
|
|
212
|
+
private handlePointerMove = (event: PointerEvent, info: EventInfo) => {
|
|
213
|
+
this.lastMoveEvent = event;
|
|
214
|
+
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
215
|
+
// Because Safari doesn't trigger mouseup events when it's above a `<select>`
|
|
216
|
+
if (isMouseEvent(event) && event.buttons === 0) {
|
|
217
|
+
this.handlePointerUp(event, info);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// Throttle mouse move event to once per frame
|
|
221
|
+
sync.update(this.updatePoint, true);
|
|
222
|
+
};
|
|
223
|
+
private handlePointerUp = (event: PointerEvent, info: EventInfo) => {
|
|
224
|
+
this.end();
|
|
225
|
+
var _a = this.handlers, onEnd = _a.onEnd, onSessionEnd = _a.onSessionEnd;
|
|
226
|
+
var panInfo = getPanInfo(transformPoint(info, this.transformPagePoint), this.history);
|
|
227
|
+
if (this.startEvent && onEnd) {
|
|
228
|
+
onEnd(event, panInfo);
|
|
229
|
+
}
|
|
230
|
+
onSessionEnd && onSessionEnd(event, panInfo);
|
|
231
|
+
};
|
|
232
|
+
updateHandlers(handlers: Partial<PanSessionHandlers>){
|
|
233
|
+
this.handlers = handlers;
|
|
234
|
+
};
|
|
235
|
+
end() {
|
|
236
|
+
this.removeListeners && this.removeListeners();
|
|
237
|
+
cancelSync.update(this.updatePoint);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
function transformPoint(info: EventInfo, transformPagePoint?: (point: Point2D) => Point2D) {
|
|
243
|
+
return transformPagePoint ? { point: transformPagePoint(info.point) } : info;
|
|
244
|
+
}
|
|
245
|
+
function subtractPoint(a: Point2D, b: Point2D): Point2D {
|
|
246
|
+
return { x: a.x - b.x, y: a.y - b.y };
|
|
247
|
+
}
|
|
248
|
+
function getPanInfo(_a: EventInfo, history: TimestampedPoint[]) {
|
|
249
|
+
var point = _a.point;
|
|
250
|
+
return {
|
|
251
|
+
point: point,
|
|
252
|
+
delta: subtractPoint(point, lastDevicePoint(history)),
|
|
253
|
+
offset: subtractPoint(point, startDevicePoint(history)),
|
|
254
|
+
velocity: getVelocity(history, 0.1),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function startDevicePoint(history: TimestampedPoint[]) {
|
|
258
|
+
return history[0];
|
|
259
|
+
}
|
|
260
|
+
function lastDevicePoint(history: TimestampedPoint[]) {
|
|
261
|
+
return history[history.length - 1];
|
|
262
|
+
}
|
|
263
|
+
function getVelocity(history: TimestampedPoint[], timeDelta: number) {
|
|
264
|
+
if (history.length < 2) {
|
|
265
|
+
return { x: 0, y: 0 };
|
|
266
|
+
}
|
|
267
|
+
var i = history.length - 1;
|
|
268
|
+
var timestampedPoint = null;
|
|
269
|
+
var lastPoint = lastDevicePoint(history);
|
|
270
|
+
while (i >= 0) {
|
|
271
|
+
timestampedPoint = history[i];
|
|
272
|
+
if (lastPoint.timestamp - timestampedPoint.timestamp >
|
|
273
|
+
secondsToMilliseconds(timeDelta)) {
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
i--;
|
|
277
|
+
}
|
|
278
|
+
if (!timestampedPoint) {
|
|
279
|
+
return { x: 0, y: 0 };
|
|
280
|
+
}
|
|
281
|
+
var time = (lastPoint.timestamp - timestampedPoint.timestamp) / 1000;
|
|
282
|
+
if (time === 0) {
|
|
283
|
+
return { x: 0, y: 0 };
|
|
284
|
+
}
|
|
285
|
+
var currentVelocity = {
|
|
286
|
+
x: (lastPoint.x - timestampedPoint.x) / time,
|
|
287
|
+
y: (lastPoint.y - timestampedPoint.y) / time,
|
|
288
|
+
};
|
|
289
|
+
if (currentVelocity.x === Infinity) {
|
|
290
|
+
currentVelocity.x = 0;
|
|
291
|
+
}
|
|
292
|
+
if (currentVelocity.y === Infinity) {
|
|
293
|
+
currentVelocity.y = 0;
|
|
294
|
+
}
|
|
295
|
+
return currentVelocity;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// export { PanSession };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { UseDomEvent } from "../events/use-dom-event.js";
|
|
6
|
+
import { AnimationType } from "../render/utils/types.js";
|
|
7
|
+
|
|
8
|
+
export let props, visualElement;
|
|
9
|
+
$: ({ whileFocus } = props);
|
|
10
|
+
const onFocus = () => {
|
|
11
|
+
visualElement.animationState?.setActive(AnimationType.Focus, true);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onBlur = () => {
|
|
15
|
+
visualElement.animationState?.setActive(AnimationType.Focus, false);
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<UseDomEvent
|
|
20
|
+
ref={visualElement}
|
|
21
|
+
eventName="focus"
|
|
22
|
+
handler={whileFocus ? onFocus : undefined}
|
|
23
|
+
>
|
|
24
|
+
<UseDomEvent
|
|
25
|
+
ref={visualElement}
|
|
26
|
+
eventName="blur"
|
|
27
|
+
handler={whileFocus ? onBlur : undefined}
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</UseDomEvent>
|
|
31
|
+
</UseDomEvent>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { UseFocusGesture } from "./use-focus-gesture.js";
|
|
6
|
+
import { UseHoverGesture } from "./use-hover-gesture.js";
|
|
7
|
+
import { UsePanGesture } from "./use-pan-gesture.js";
|
|
8
|
+
import { UseTapGesture } from "./use-tap-gesture.js";
|
|
9
|
+
|
|
10
|
+
export let props, visualElement;
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<UsePanGesture {props} {visualElement} />
|
|
14
|
+
<UseTapGesture {props} {visualElement} />
|
|
15
|
+
<UseHoverGesture {props} {visualElement} />
|
|
16
|
+
<UseFocusGesture {props} {visualElement} />
|
|
17
|
+
<slot />
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script module lang="ts">
|
|
5
|
+
import { isDragActive } from "./drag/utils/lock.js";
|
|
6
|
+
function createHoverEvent(visualElement, isActive, callback) {
|
|
7
|
+
return (event, info) => {
|
|
8
|
+
if (!isMouseEvent(event) || isDragActive()) return;
|
|
9
|
+
callback?.(event, info);
|
|
10
|
+
|
|
11
|
+
visualElement.animationState?.setActive(AnimationType.Hover, isActive);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { UsePointerEvent } from "../events/use-pointer-event.js";
|
|
18
|
+
import { AnimationType } from "../render/utils/types.js";
|
|
19
|
+
import { isMouseEvent } from "./utils/event-type.js";
|
|
20
|
+
|
|
21
|
+
export let props, visualElement;
|
|
22
|
+
let { onHoverStart, onHoverEnd, whileHover } = props;
|
|
23
|
+
$: ({ onHoverStart, onHoverEnd, whileHover } = props);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<UsePointerEvent
|
|
27
|
+
ref={visualElement}
|
|
28
|
+
eventName="pointerenter"
|
|
29
|
+
handler={onHoverStart || whileHover
|
|
30
|
+
? createHoverEvent(visualElement, true, onHoverStart)
|
|
31
|
+
: undefined}
|
|
32
|
+
/>
|
|
33
|
+
<UsePointerEvent
|
|
34
|
+
ref={visualElement}
|
|
35
|
+
eventName="pointerleave"
|
|
36
|
+
handler={onHoverEnd || whileHover
|
|
37
|
+
? createHoverEvent(visualElement, false, onHoverEnd)
|
|
38
|
+
: undefined}
|
|
39
|
+
/>
|
|
40
|
+
<slot />
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { afterUpdate, getContext, onDestroy } from "svelte";
|
|
6
|
+
import { get } from "svelte/store";
|
|
7
|
+
import { MotionConfigContext } from "../context/MotionConfigContext.js";
|
|
8
|
+
import { UsePointerEvent } from "../events/use-pointer-event";
|
|
9
|
+
import { PanSession } from "./PanSession";
|
|
10
|
+
|
|
11
|
+
export let props,
|
|
12
|
+
visualElement,
|
|
13
|
+
isCustom = false;
|
|
14
|
+
let { onPan, onPanStart, onPanEnd, onPanSessionStart } = props;
|
|
15
|
+
$: ({ onPan, onPanStart, onPanEnd, onPanSessionStart } = props);
|
|
16
|
+
$: hasPanEvents = onPan || onPanStart || onPanEnd || onPanSessionStart;
|
|
17
|
+
let panSession = null;
|
|
18
|
+
const mcc = getContext(MotionConfigContext) || MotionConfigContext(isCustom);
|
|
19
|
+
let { transformPagePoint } = get(mcc);
|
|
20
|
+
$: ({ transformPagePoint } = $mcc);
|
|
21
|
+
let handlers = {
|
|
22
|
+
onSessionStart: onPanSessionStart,
|
|
23
|
+
onStart: onPanStart,
|
|
24
|
+
onMove: onPan,
|
|
25
|
+
onEnd: (event, info) => {
|
|
26
|
+
panSession = null;
|
|
27
|
+
onPanEnd && onPanEnd(event, info);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
$: handlers = {
|
|
31
|
+
onSessionStart: onPanSessionStart,
|
|
32
|
+
onStart: onPanStart,
|
|
33
|
+
onMove: onPan,
|
|
34
|
+
onEnd: (event, info) => {
|
|
35
|
+
panSession = null;
|
|
36
|
+
onPanEnd && onPanEnd(event, info);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
function onPointerDown(event) {
|
|
40
|
+
panSession = new PanSession(event, handlers, {
|
|
41
|
+
transformPagePoint,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
afterUpdate(() => {
|
|
45
|
+
if (panSession !== null) {
|
|
46
|
+
panSession.updateHandlers(handlers);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
onDestroy(() => panSession && panSession.end());
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<UsePointerEvent
|
|
53
|
+
ref={visualElement}
|
|
54
|
+
eventName="pointerdown"
|
|
55
|
+
handler={hasPanEvents && onPointerDown}
|
|
56
|
+
>
|
|
57
|
+
<slot />
|
|
58
|
+
</UsePointerEvent>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { pipe } from "popmotion";
|
|
6
|
+
import { onDestroy } from "svelte";
|
|
7
|
+
import {
|
|
8
|
+
UsePointerEvent,
|
|
9
|
+
addPointerEvent,
|
|
10
|
+
} from "../events/use-pointer-event.js";
|
|
11
|
+
import { AnimationType } from "../render/utils/types.js";
|
|
12
|
+
import { isDragActive } from "./drag/utils/lock.js";
|
|
13
|
+
import { isNodeOrChild } from "./utils/is-node-or-child.js";
|
|
14
|
+
|
|
15
|
+
export let props, visualElement;
|
|
16
|
+
|
|
17
|
+
$: ({ onTap, onTapStart, onTapCancel, whileTap } = props);
|
|
18
|
+
$: hasPressListeners = onTap || onTapStart || onTapCancel || whileTap;
|
|
19
|
+
|
|
20
|
+
let isPressing = false;
|
|
21
|
+
let cancelPointerEndListeners = null;
|
|
22
|
+
|
|
23
|
+
function removePointerEndListener() {
|
|
24
|
+
cancelPointerEndListeners?.();
|
|
25
|
+
cancelPointerEndListeners = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function checkPointerEnd() {
|
|
29
|
+
removePointerEndListener();
|
|
30
|
+
isPressing = false;
|
|
31
|
+
visualElement.animationState?.setActive(AnimationType.Tap, false);
|
|
32
|
+
return !isDragActive();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function onPointerUp(event, info) {
|
|
36
|
+
if (!checkPointerEnd()) return;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* We only count this as a tap gesture if the event.target is the same
|
|
40
|
+
* as, or a child of, this component's element
|
|
41
|
+
*/
|
|
42
|
+
!isNodeOrChild(visualElement.getInstance(), event.target)
|
|
43
|
+
? onTapCancel?.(event, info)
|
|
44
|
+
: onTap?.(event, info);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onPointerCancel(event, info) {
|
|
48
|
+
if (!checkPointerEnd()) return;
|
|
49
|
+
|
|
50
|
+
onTapCancel?.(event, info);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function onPointerDown(event, info) {
|
|
54
|
+
if (isPressing) return;
|
|
55
|
+
removePointerEndListener();
|
|
56
|
+
isPressing = true;
|
|
57
|
+
|
|
58
|
+
cancelPointerEndListeners = pipe(
|
|
59
|
+
addPointerEvent(window, "pointerup", onPointerUp),
|
|
60
|
+
addPointerEvent(window, "pointercancel", onPointerCancel)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
onTapStart?.(event, info);
|
|
64
|
+
|
|
65
|
+
visualElement.animationState?.setActive(AnimationType.Tap, true);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onDestroy(removePointerEndListener);
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<UsePointerEvent
|
|
72
|
+
ref={visualElement}
|
|
73
|
+
eventName="pointerdown"
|
|
74
|
+
handler={hasPressListeners ? onPointerDown : undefined}
|
|
75
|
+
>
|
|
76
|
+
<slot />
|
|
77
|
+
</UsePointerEvent>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.1.11,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { getContext, onDestroy, onMount } from "svelte";
|
|
6
|
+
import { get, type Writable } from "svelte/store";
|
|
7
|
+
import {
|
|
8
|
+
MotionConfigContext,
|
|
9
|
+
type MotionConfigContextObject,
|
|
10
|
+
} from "../../context/MotionConfigContext.js";
|
|
11
|
+
import { VisualElementDragControls } from "./VisualElementDragControls.js";
|
|
12
|
+
|
|
13
|
+
export let visualElement, props, isCustom;
|
|
14
|
+
|
|
15
|
+
const mcc: Writable<MotionConfigContextObject> =
|
|
16
|
+
getContext(MotionConfigContext) || MotionConfigContext(isCustom);
|
|
17
|
+
|
|
18
|
+
let dragControls = new VisualElementDragControls({
|
|
19
|
+
visualElement,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// If we've been provided a DragControls for manual control over the drag gesture,
|
|
23
|
+
// subscribe this component to it on mount.
|
|
24
|
+
let cleanup;
|
|
25
|
+
const dragEffect = () => {
|
|
26
|
+
if (cleanup) {
|
|
27
|
+
cleanup();
|
|
28
|
+
}
|
|
29
|
+
if (groupDragControls) {
|
|
30
|
+
cleanup = groupDragControls.subscribe(dragControls);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
let { dragControls: groupDragControls } = props;
|
|
34
|
+
let { transformPagePoint } = get(mcc);
|
|
35
|
+
|
|
36
|
+
$: ({ dragControls: groupDragControls } = props);
|
|
37
|
+
//let {transformPagePoint} = get($mcc);
|
|
38
|
+
$: ({ transformPagePoint } = $mcc);
|
|
39
|
+
dragControls.setProps({ ...props, transformPagePoint });
|
|
40
|
+
|
|
41
|
+
//dragControls.setProps({ ...props, transformPagePoint })
|
|
42
|
+
|
|
43
|
+
$: dragControls.setProps({ ...props, transformPagePoint });
|
|
44
|
+
|
|
45
|
+
$: dragEffect(dragControls);
|
|
46
|
+
|
|
47
|
+
onDestroy(() => {
|
|
48
|
+
if (cleanup) {
|
|
49
|
+
cleanup();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
onMount(() => dragControls.mount(visualElement));
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<slot />
|