motion-dom 14.9.1 → 14.10.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/dist/cjs/index.js +729 -183
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/GroupAnimation.mjs +21 -15
- package/dist/es/animation/GroupAnimation.mjs.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +6 -0
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +5 -0
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/animate/effects.mjs +15 -4
- package/dist/es/animation/animate/effects.mjs.map +1 -1
- package/dist/es/animation/animate/single-value.mjs +1 -1
- package/dist/es/animation/animate/single-value.mjs.map +1 -1
- package/dist/es/animation/generators/keyframes.mjs +44 -16
- package/dist/es/animation/generators/keyframes.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +8 -3
- package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
- package/dist/es/animation/keyframes/get-final.mjs +18 -4
- package/dist/es/animation/keyframes/get-final.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +347 -88
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +3 -3
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/gestures/drag/index.mjs +4 -1
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +6 -2
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/gestures/press/index.mjs +179 -8
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/gestures/press/utils/keyboard.mjs +1 -1
- package/dist/es/gestures/press/utils/keyboard.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +39 -17
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/value/index.mjs +24 -20
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/es/value/types/utils/animatable-none.mjs +13 -1
- package/dist/es/value/types/utils/animatable-none.mjs.map +1 -1
- package/dist/index.d.ts +163 -13
- package/dist/motion-dom.dev.js +729 -183
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualElementDragControls.mjs","sources":["../../../../src/gestures/drag/VisualElementDragControls.ts"],"sourcesContent":["import { Axis, invariant, Point } from \"motion-utils\"\nimport { animateMotionValue } from \"../../animation/interfaces/motion-value\"\nimport type { Transition } from \"../../animation/types\"\nimport { getVariableValue } from \"../../animation/utils/css-variables-conversion\"\nimport { isCSSVariableToken } from \"../../animation/utils/is-css-variable\"\nimport { addDomEvent } from \"../../events/add-dom-event\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { frame } from \"../../frameloop/frame\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport {\n convertBoundingBoxToBox,\n convertBoxToBoundingBox,\n} from \"../../projection/geometry/conversion\"\nimport { calcLength } from \"../../projection/geometry/delta-calc\"\nimport { createBox } from \"../../projection/geometry/models\"\nimport type {\n IProjectionNode,\n LayoutUpdateData,\n} from \"../../projection/node/types\"\nimport { eachAxis } from \"../../projection/utils/each-axis\"\nimport { measurePageBox } from \"../../projection/utils/measure\"\nimport type { VisualElement } from \"../../render/VisualElement\"\nimport { resize } from \"../../resize\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { percent, px } from \"../../value/types/numbers/units\"\nimport { addValueToWillChange } from \"../../value/will-change/add-will-change\"\nimport type { PanInfo } from \"../pan/types\"\nimport { PanSession } from \"../pan/PanSession\"\nimport { isElementTextInput } from \"../press/utils/is-keyboard-accessible\"\nimport { setDragLock } from \"./state/set-active\"\nimport type { DragPointConstraint, ResolvedConstraints } from \"./types\"\nimport {\n applyConstraints,\n calcOrigin,\n calcRelativeConstraints,\n calcViewportConstraints,\n defaultElastic,\n rebaseAxisConstraints,\n resolveDragElastic,\n} from \"./utils/constraints\"\n\n/**\n * Re-read the scroll of the projection's ancestors, and return that of the\n * `layoutScroll` ones as a key that changes when any of them scroll.\n *\n * Clear the cached scroll first so `updateScroll` bypasses its\n * per-animationId cache and re-reads the live value.\n */\nfunction measureScroll(projection: IProjectionNode) {\n let key = \"\"\n\n for (const node of projection.path) {\n node.scroll = undefined\n node.updateScroll()\n\n const { scroll } = node as IProjectionNode\n if (node !== projection.root && scroll) {\n key += scroll.offset.x + \",\" + scroll.offset.y + \",\"\n }\n }\n\n return key\n}\n\nexport const elementDragControls = new WeakMap<\n VisualElement,\n VisualElementDragControls\n>()\n\nexport interface DragControlOptions {\n /**\n * This distance after which dragging starts and a direction is locked in.\n *\n * @public\n */\n distanceThreshold?: number\n\n /**\n * Whether to immediately snap to the cursor when dragging starts.\n *\n * @public\n */\n snapToCursor?: boolean\n}\n\ntype DragDirection = \"x\" | \"y\"\n\nexport class VisualElementDragControls {\n visualElement: VisualElement<HTMLElement>\n\n private panSession?: PanSession\n\n private openDragLock: VoidFunction | null = null\n\n isDragging = false\n private currentDirection: DragDirection | null = null\n\n originPoint: Point = { x: 0, y: 0 }\n\n /**\n * The permitted boundaries of travel, in pixels.\n */\n private constraints: ResolvedConstraints | false = false\n\n private hasMutatedConstraints = false\n\n /**\n * A constraint, from a `dragConstraints` function, that moves the\n * element itself, from the drag's latest pointer position.\n */\n private point?: DragPointConstraint | false\n\n /**\n * The `layoutScroll` ancestors' scroll (see measureScroll) when ref\n * constraints were last measured.\n */\n private scroll?: string\n\n /**\n * The per-axis resolved elastic values.\n */\n elastic = createBox()\n\n /**\n * The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n private latestPointerEvent: PointerEvent | null = null\n\n /**\n * The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n private latestPanInfo: PanInfo | null = null\n\n /**\n * Where drag options are read from. By default these are the\n * VisualElement's props (as with a React `motion` component), but the\n * vanilla `drag()` API provides its own.\n */\n private readProps: () => MotionNodeOptions\n\n constructor(\n visualElement: VisualElement<HTMLElement>,\n readProps: () => MotionNodeOptions = () => visualElement.getProps()\n ) {\n this.visualElement = visualElement\n this.readProps = readProps\n }\n\n start(\n originEvent: PointerEvent,\n { snapToCursor = false, distanceThreshold }: DragControlOptions = {}\n ) {\n /**\n * Don't start dragging if this component is exiting\n */\n if (this.visualElement.presenceContext?.isPresent === false) return\n\n const onSessionStart = (event: PointerEvent) => {\n if (snapToCursor) this.snapToCursor(event)\n this.stopAnimation()\n }\n\n const onStart = (event: PointerEvent, info: PanInfo) => {\n // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n const { drag, dragConstraints, dragPropagation, onDragStart } =\n this.getProps()\n\n if (drag && !dragPropagation) {\n this.openDragLock?.()\n\n this.openDragLock = setDragLock(drag)\n\n // If we don 't have the lock, don't start dragging\n if (!this.openDragLock) return\n }\n\n this.latestPointerEvent = event\n this.latestPanInfo = info\n this.isDragging = true\n\n this.currentDirection = null\n\n this.resolveConstraints()\n\n const { projection } = this.visualElement\n if (projection) {\n projection.isAnimationBlocked = true\n projection.target = undefined\n }\n\n /**\n * Record gesture origin and pointer offset\n */\n eachAxis((axis) => {\n let current = this.getAxisMotionValue(axis).get() || 0\n\n /**\n * If the MotionValue is a CSS variable, like \"var(--y)\",\n * resolve it so it can be converted to px below.\n */\n if (isCSSVariableToken(current)) {\n current =\n getVariableValue(\n current,\n this.visualElement.current!\n ) || 0\n }\n\n /**\n * If the MotionValue is a px or percentage value convert to px\n */\n if (px.test(current)) {\n current = parseFloat(current)\n } else if (percent.test(current)) {\n const measuredAxis = projection?.layout?.layoutBox[axis]\n\n if (measuredAxis) {\n current =\n calcLength(measuredAxis) *\n (parseFloat(current) / 100)\n }\n }\n\n this.originPoint[axis] = current\n })\n\n this.point =\n typeof dragConstraints === \"function\" && dragConstraints(this)\n\n // Fire onDragStart event\n if (onDragStart) {\n frame.update(() => onDragStart(event, info), false, true)\n }\n\n addValueToWillChange(this.visualElement, \"transform\")\n\n this.visualElement.animationState?.setActive(\"whileDrag\", true)\n }\n\n const onMove = (event: PointerEvent, info: PanInfo) => {\n this.latestPointerEvent = event\n this.latestPanInfo = info\n\n const {\n dragPropagation,\n dragDirectionLock,\n onDirectionLock,\n onDrag,\n } = this.getProps()\n\n // If we didn't successfully receive the gesture lock, early return.\n if (!dragPropagation && !this.openDragLock) return\n\n const { offset } = info\n // Attempt to detect drag direction if directionLock is true\n if (dragDirectionLock && this.currentDirection === null) {\n this.currentDirection = getCurrentDirection(offset)\n\n /**\n * Wait for more movement until a direction is set. Once\n * it is, apply this move too: it can be the last before\n * release when the browser coalesces a fast gesture.\n */\n if (this.currentDirection === null) return\n\n onDirectionLock && onDirectionLock(this.currentDirection)\n }\n\n // Update each point with the latest position\n this.updateAxis(\"x\", offset)\n this.updateAxis(\"y\", offset)\n this.point && this.point.move()\n\n /**\n * Ideally we would leave the renderer to fire naturally at the end of\n * this frame but if the element is about to change layout as the result\n * of a re-render we want to ensure the browser can read the latest\n * bounding box to ensure the pointer and element don't fall out of sync.\n */\n this.visualElement.render()\n\n /**\n * This must fire after the render call as it might trigger a state\n * change which itself might trigger a layout update.\n */\n if (onDrag) {\n frame.update(() => onDrag(event, info), false, true)\n }\n }\n\n const onSessionEnd = (event: PointerEvent, info: PanInfo) => {\n this.latestPointerEvent = event\n this.latestPanInfo = info\n\n this.stop(event, info)\n\n this.latestPointerEvent = null\n this.latestPanInfo = null\n }\n\n const resumeAnimation = () => {\n const { dragSnapToOrigin: snap } = this.getProps()\n if (snap || this.constraints || this.point) {\n this.startAnimation({ x: 0, y: 0 })\n }\n }\n\n const { dragSnapToOrigin } = this.getProps()\n this.panSession = new PanSession(\n originEvent,\n {\n onSessionStart,\n onStart,\n onMove,\n onSessionEnd,\n resumeAnimation,\n },\n {\n transformPagePoint: this.visualElement.getTransformPagePoint(),\n dragSnapToOrigin,\n distanceThreshold,\n contextWindow:\n this.visualElement.current?.ownerDocument.defaultView,\n element: this.visualElement.current,\n }\n )\n }\n\n /**\n * @param dragAxes - The axes to animate on release, if not the `drag`\n * prop's, e.g. when drag was disabled mid-gesture.\n */\n stop(\n event?: PointerEvent,\n panInfo?: PanInfo,\n dragAxes?: MotionNodeOptions[\"drag\"]\n ) {\n const finalEvent = event || this.latestPointerEvent\n const finalPanInfo = panInfo || this.latestPanInfo\n\n const isDragging = this.isDragging\n this.cancel()\n if (!isDragging || !finalPanInfo || !finalEvent) return\n\n const { velocity } = finalPanInfo\n this.startAnimation(velocity, dragAxes)\n\n const { onDragEnd } = this.getProps()\n if (onDragEnd) {\n frame.postRender(() => onDragEnd(finalEvent, finalPanInfo))\n }\n }\n\n cancel() {\n this.isDragging = false\n\n const { projection, animationState } = this.visualElement\n\n if (projection) {\n projection.isAnimationBlocked = false\n }\n\n this.endPanSession()\n\n if (!this.getProps().dragPropagation && this.openDragLock) {\n this.openDragLock()\n this.openDragLock = null\n }\n\n animationState?.setActive(\"whileDrag\", false)\n }\n\n /**\n * Clean up the pan session without modifying other drag state.\n * This is used during unmount to ensure event listeners are removed\n * without affecting projection animations or drag locks.\n */\n endPanSession() {\n this.panSession?.end()\n this.panSession = undefined\n }\n\n private updateAxis(axis: DragDirection, offset?: Point) {\n /**\n * Read drag per axis: a callback fired while updating the x axis\n * can synchronously re-render with new props.\n */\n const { drag } = this.readProps()\n\n // If we're not dragging this axis, do an early return.\n if (!offset || !shouldDrag(axis, drag, this.currentDirection)) return\n\n const axisValue = this.getAxisMotionValue(axis)\n let next = this.originPoint[axis] + offset[axis]\n\n // Apply constraints\n const constraints = this.constraints && this.constraints[axis]\n if (constraints) {\n next = applyConstraints(next, constraints, this.elastic[axis])\n }\n\n this.point ? (this.point[axis] = next) : axisValue.set(next)\n }\n\n private resolveConstraints() {\n const { dragConstraints, dragElastic } = this.getProps()\n\n const { projection } = this.visualElement\n const layout =\n projection && (projection.layout || projection.measure(false))\n\n const prevConstraints = this.constraints\n\n if (isElementConstraints(dragConstraints)) {\n /**\n * Ref constraints are measured with the layout. Scrolling a\n * `layoutScroll` ancestor since can move the element relative\n * to them without a layout measurement, so measure them again\n * (#2024). Otherwise keep them: they and the layout can both\n * have moved on the page since, e.g. when content above grows.\n */\n if (\n !this.constraints ||\n this.scroll !== measureScroll(projection!)\n ) {\n this.constraints = this.resolveRefConstraints()\n }\n } else {\n if (\n dragConstraints &&\n layout &&\n typeof dragConstraints === \"object\"\n ) {\n this.constraints = calcRelativeConstraints(\n layout.layoutBox,\n dragConstraints\n )\n } else {\n this.constraints = false\n }\n }\n\n this.elastic = resolveDragElastic(dragElastic)\n\n /**\n * If we're outputting to external MotionValues, we want to rebase the measured constraints\n * from viewport-relative to component-relative. This only applies to relative (non-ref)\n * constraints, as ref-based constraints from calcViewportConstraints are already in the\n * correct coordinate space for the motion value transform offset.\n */\n if (\n prevConstraints !== this.constraints &&\n !isElementConstraints(dragConstraints) &&\n layout &&\n this.constraints &&\n !this.hasMutatedConstraints\n ) {\n eachAxis((axis) => {\n if (\n this.constraints !== false &&\n this.getAxisMotionValue(axis)\n ) {\n this.constraints[axis] = rebaseAxisConstraints(\n layout.layoutBox[axis],\n this.constraints[axis]\n )\n }\n })\n }\n }\n\n private resolveRefConstraints() {\n const { dragConstraints: constraints, onMeasureDragConstraints } =\n this.getProps()\n if (!isElementConstraints(constraints)) return false\n\n const constraintsElement = resolveConstraintsElement(constraints)\n\n process.env.NODE_ENV !== \"production\" &&\n invariant(\n !!constraintsElement,\n \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\",\n \"drag-constraints-ref\"\n )\n\n const { projection } = this.visualElement\n\n // TODO\n if (!projection || !projection.layout) return false\n\n /**\n * Refresh the scroll offsets of the root and `layoutScroll`\n * ancestors so the constraint's viewport box translates to the\n * layout's coordinates. The scroll captured when the layout was\n * measured can be stale if they've scrolled since — e.g. via the\n * browser restoring scroll on refresh, or an ancestor layout effect\n * running after this element's mount (#2829).\n */\n this.scroll = measureScroll(projection)\n\n const constraintsBox = measurePageBox(\n constraintsElement as HTMLElement,\n projection.root!,\n this.visualElement.getTransformPagePoint()\n )\n\n /**\n * layoutBox removes the scroll of `layoutScroll` ancestors, so\n * remove it from the constraints box too.\n */\n let measuredConstraints = calcViewportConstraints(\n projection.layout.layoutBox,\n projection.removeElementScroll(constraintsBox)\n )\n\n /**\n * If there's an onMeasureDragConstraints listener we call it and\n * if different constraints are returned, set constraints to that\n */\n if (onMeasureDragConstraints) {\n const userConstraints = onMeasureDragConstraints(\n convertBoxToBoundingBox(measuredConstraints)\n )\n\n this.hasMutatedConstraints = !!userConstraints\n\n if (userConstraints) {\n measuredConstraints = convertBoundingBoxToBox(userConstraints)\n }\n }\n\n return measuredConstraints\n }\n\n private startAnimation(\n velocity: Point,\n dragAxes?: MotionNodeOptions[\"drag\"]\n ) {\n const {\n drag,\n dragMomentum,\n dragElastic,\n dragTransition,\n dragSnapToOrigin,\n onDragTransitionEnd,\n } = this.getProps()\n\n /**\n * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n * of spring animations so we should look into adding a disable spring option to `inertia`.\n * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n * using the value of `dragElastic`.\n */\n const options = {\n bounceStiffness: dragElastic ? 200 : 1000000,\n bounceDamping: dragElastic ? 40 : 10000000,\n timeConstant: 750,\n restDelta: 1,\n restSpeed: 10,\n ...dragTransition,\n }\n\n const axisVelocity = (axis: DragDirection) =>\n dragMomentum &&\n !(this.point && dragSnapToOrigin) &&\n shouldDrag(axis, dragAxes || drag, this.currentDirection)\n ? velocity[axis]\n : 0\n\n if (this.point && !dragSnapToOrigin) {\n return this.point\n .release(\n { x: axisVelocity(\"x\"), y: axisVelocity(\"y\") },\n options\n )\n .then(onDragTransitionEnd)\n }\n\n const constraints: Partial<ResolvedConstraints> = this.constraints || {}\n\n const momentumAnimations = eachAxis((axis) => {\n if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {\n return\n }\n\n let transition = constraints[axis] || {}\n\n if (\n dragSnapToOrigin === true ||\n (dragSnapToOrigin as unknown) === axis\n )\n transition = { min: 0, max: 0 }\n\n const inertia: Transition = {\n type: \"inertia\",\n velocity: axisVelocity(axis),\n ...options,\n ...transition,\n }\n\n // If we're not animating on an externally-provided `MotionValue` we can use the\n // component's animation controls which will handle interactions with whileHover (etc),\n // otherwise we just have to animate the `MotionValue` itself.\n return this.startAxisValueAnimation(axis, inertia)\n })\n\n // Run all animations and then resolve the new drag constraints.\n return Promise.all(momentumAnimations).then(onDragTransitionEnd)\n }\n\n private startAxisValueAnimation(\n axis: DragDirection,\n transition: Transition\n ) {\n const axisValue = this.getAxisMotionValue(axis)\n\n addValueToWillChange(this.visualElement, axis)\n\n return axisValue.start(\n animateMotionValue(\n axis,\n axisValue,\n 0,\n transition,\n this.visualElement,\n false\n )\n )\n }\n\n stopAnimation() {\n eachAxis((axis) => this.getAxisMotionValue(axis).stop())\n }\n\n /**\n * Drag works differently depending on which props are provided.\n *\n * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n * - Otherwise, we apply the delta to the x/y motion values.\n */\n getAxisMotionValue(axis: DragDirection) {\n const dragKey =\n `_drag${axis.toUpperCase()}` as `_drag${Uppercase<DragDirection>}`\n const props = this.readProps()\n const externalMotionValue = props[dragKey]\n\n return externalMotionValue\n ? externalMotionValue\n : this.visualElement.getValue(\n axis,\n this.visualElement.latestValues[axis] ?? 0\n )\n }\n\n /**\n * Measure the live box - projection.layout may or may not include the\n * drag transform, depending on when it was measured.\n */\n private snapToCursor({ clientX, clientY }: PointerEvent) {\n const { drag } = this.getProps()\n const point = { x: clientX, y: clientY }\n const cursor =\n this.visualElement.getTransformPagePoint()?.(point) || point\n const box = this.visualElement.measureViewportBox()\n\n eachAxis((axis) => {\n if (!shouldDrag(axis, drag, this.currentDirection)) return\n\n const axisValue = this.getAxisMotionValue(axis)\n const { min, max } = box[axis]\n\n axisValue.set(\n (axisValue.get() || 0) + cursor[axis] - mixNumber(min, max, 0.5)\n )\n })\n }\n\n /**\n * When the viewport resizes we want to check if the measured constraints\n * have changed and, if so, reposition the element within those new constraints\n * relative to where it was before the resize.\n */\n scalePositionWithinConstraints() {\n if (!this.visualElement.current) return\n\n const { drag, dragConstraints } = this.getProps()\n const { projection } = this.visualElement\n if (\n !isElementConstraints(dragConstraints) ||\n !projection ||\n !this.constraints\n )\n return\n\n /**\n * Stop current animations as there can be visual glitching if we try to do\n * this mid-animation\n */\n this.stopAnimation()\n\n /**\n * Record the relative position of the dragged element relative to the\n * constraints box and save as a progress value.\n */\n const constraints = this.constraints as ResolvedConstraints\n const boxProgress = { x: 0, y: 0 }\n eachAxis((axis) => {\n const latest = this.getAxisMotionValue(axis).get()\n boxProgress[axis] = calcOrigin(\n { min: latest, max: latest },\n constraints[axis] as Axis\n )\n })\n\n /**\n * Update the layout of this element and resolve the latest drag constraints\n */\n const { transformTemplate } = this.visualElement.getProps()\n this.visualElement.current.style.transform = transformTemplate\n ? transformTemplate({}, \"\")\n : \"none\"\n projection.root?.updateScroll()\n projection.updateLayout()\n\n /**\n * Reset constraints so resolveConstraints() will recalculate them\n * with the freshly measured layout rather than returning the cached value.\n */\n this.constraints = false\n this.resolveConstraints()\n\n /**\n * For each axis, calculate the current progress of the layout axis\n * within the new constraints.\n */\n eachAxis((axis) => {\n const axisValue = this.getAxisMotionValue(axis)\n\n /**\n * An element resting at its origin has no offset to preserve,\n * and re-projecting 0 into the new constraints would move it.\n */\n if (!shouldDrag(axis, drag, null) || !axisValue.get()) return\n\n /**\n * Calculate a new transform based on the previous box progress\n */\n const { min, max } = (this.constraints as ResolvedConstraints)[\n axis\n ] as Axis\n axisValue.set(mixNumber(min, max, boxProgress[axis]))\n })\n\n /**\n * Flush the updated transform to the DOM synchronously to prevent\n * a visual flash at the element's CSS layout position (0,0) when\n * the transform was stripped for measurement.\n */\n this.visualElement.render()\n }\n\n addListeners() {\n if (!this.visualElement.current) return\n elementDragControls.set(this.visualElement, this)\n const element = this.visualElement.current\n\n /**\n * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n */\n const stopPointerListener = addPointerEvent(\n element,\n \"pointerdown\",\n (event) => {\n const { drag, dragListener = true } = this.getProps()\n const target = event.target as Element\n\n /**\n * Only block drag if clicking on a text input child element\n * (input, textarea, select, contenteditable) where users might\n * want to select text or interact with the control.\n *\n * Buttons and links don't block drag since they don't have\n * click-and-move actions of their own.\n */\n const isClickingTextInputChild =\n target !== element && isElementTextInput(target)\n\n if (drag && dragListener && !isClickingTextInputChild) {\n this.start(event)\n }\n }\n )\n\n /**\n * If using ref-based constraints, observe both the draggable element\n * and the constraint container for size changes via ResizeObserver.\n * Setup is deferred because dragConstraints.current is null when\n * addListeners first runs (React hasn't committed the ref yet).\n */\n let stopResizeObservers: VoidFunction | undefined\n\n const measureDragConstraints = () => {\n const { dragConstraints } = this.getProps()\n const constraintsElement =\n isElementConstraints(dragConstraints) &&\n resolveConstraintsElement(dragConstraints)\n\n if (constraintsElement) {\n this.constraints = this.resolveRefConstraints()\n\n if (!stopResizeObservers) {\n stopResizeObservers = startResizeObservers(\n element,\n constraintsElement as HTMLElement,\n () => this.scalePositionWithinConstraints()\n )\n }\n }\n }\n\n const { projection } = this.visualElement\n\n const stopMeasureLayoutListener = projection!.addEventListener(\n \"measure\",\n measureDragConstraints\n )\n\n if (!projection!.layout) {\n projection!.root?.updateScroll()\n projection!.updateLayout()\n }\n\n frame.read(measureDragConstraints)\n\n /**\n * Attach a window resize listener to scale the draggable target within its defined\n * constraints as the window resizes.\n */\n const stopResizeListener = addDomEvent(window, \"resize\", () =>\n this.scalePositionWithinConstraints()\n )\n\n /**\n * If the element's layout changes, calculate the delta and apply that to\n * the drag gesture's origin point.\n */\n const stopLayoutUpdateListener = projection!.addEventListener(\n \"didUpdate\",\n (({ delta, hasLayoutChanged }: LayoutUpdateData) => {\n if (this.isDragging && hasLayoutChanged) {\n eachAxis((axis) => {\n /**\n * Only compensate axes this gesture drags. A\n * non-drag axis follows its layout instead, as\n * nothing would ever move it back (e.g. snapping\n * to origin only animates drag axes).\n */\n if (\n !shouldDrag(\n axis,\n this.getProps().drag,\n this.currentDirection\n )\n )\n return\n\n const motionValue = this.getAxisMotionValue(axis)\n this.originPoint[axis] += delta[axis].translate\n motionValue.set(\n motionValue.get() + delta[axis].translate\n )\n })\n\n this.visualElement.render()\n }\n }) as any\n )\n\n return () => {\n stopResizeListener()\n stopPointerListener()\n stopMeasureLayoutListener()\n stopLayoutUpdateListener()\n stopResizeObservers?.()\n }\n }\n\n getProps(): MotionNodeOptions {\n const props = this.readProps()\n const { dragElastic = defaultElastic, dragMomentum = true } = props\n return { ...props, dragElastic, dragMomentum }\n }\n}\n\ntype ConstraintsElement = Element | { current: Element | null }\n\n/**\n * `dragConstraints` can be an element, or a ref (`{ current }`) to one.\n */\nfunction isElementConstraints(\n constraints: MotionNodeOptions[\"dragConstraints\"]\n): constraints is ConstraintsElement {\n return (\n !!constraints &&\n typeof constraints === \"object\" &&\n (\"current\" in constraints || \"nodeType\" in constraints)\n )\n}\n\nconst resolveConstraintsElement = (constraints: ConstraintsElement) =>\n \"current\" in constraints ? constraints.current : constraints\n\nfunction skipFirstCall(callback: VoidFunction): VoidFunction {\n let isFirst = true\n return () => {\n if (isFirst) {\n isFirst = false\n return\n }\n callback()\n }\n}\n\nfunction startResizeObservers(\n element: HTMLElement,\n constraintsElement: HTMLElement,\n onResize: VoidFunction\n): VoidFunction {\n const stopElement = resize(element, skipFirstCall(onResize))\n const stopContainer = resize(constraintsElement, skipFirstCall(onResize))\n return () => {\n stopElement()\n stopContainer()\n }\n}\n\nfunction shouldDrag(\n direction: DragDirection,\n drag: boolean | DragDirection | undefined,\n currentDirection: null | DragDirection\n) {\n return (\n (drag === true || drag === direction) &&\n (currentDirection === null || currentDirection === direction)\n )\n}\n\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(\n offset: Point,\n lockThreshold = 10\n): DragDirection | null {\n let direction: DragDirection | null = null\n\n if (Math.abs(offset.y) > lockThreshold) {\n direction = \"y\"\n } else if (Math.abs(offset.x) > lockThreshold) {\n direction = \"x\"\n }\n\n return direction\n}\n\nexport function expectsResolvedDragConstraints({\n dragConstraints,\n onMeasureDragConstraints,\n}: MotionNodeOptions) {\n return isElementConstraints(dragConstraints) && !!onMeasureDragConstraints\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;AAMG;AACH,SAAS,aAAa,CAAC,UAA2B,EAAA;IAC9C,IAAI,GAAG,GAAG,EAAE;AAEZ,IAAA,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE;AAChC,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS;QACvB,IAAI,CAAC,YAAY,EAAE;AAEnB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAuB;QAC1C,IAAI,IAAI,KAAK,UAAU,CAAC,IAAI,IAAI,MAAM,EAAE;AACpC,YAAA,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG;QACxD;IACJ;AAEA,IAAA,OAAO,GAAG;AACd;AAEO,MAAM,mBAAmB,GAAG,IAAI,OAAO;MAuBjC,yBAAyB,CAAA;IAqDlC,WAAA,CACI,aAAyC,EACzC,SAAA,GAAqC,MAAM,aAAa,CAAC,QAAQ,EAAE,EAAA;QAlD/D,IAAA,CAAA,YAAY,GAAwB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AAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE;QACpC,SAAS,GAAG,GAAG;IACnB;SAAO,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE;QAC3C,SAAS,GAAG,GAAG;IACnB;AAEA,IAAA,OAAO,SAAS;AACpB;SAEgB,8BAA8B,CAAC,EAC3C,eAAe,EACf,wBAAwB,GACR,EAAA;IAChB,OAAO,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,wBAAwB;AAC9E;;;;"}
|
|
1
|
+
{"version":3,"file":"VisualElementDragControls.mjs","sources":["../../../../src/gestures/drag/VisualElementDragControls.ts"],"sourcesContent":["import { Axis, invariant, Point } from \"motion-utils\"\nimport { animateMotionValue } from \"../../animation/interfaces/motion-value\"\nimport type { Transition } from \"../../animation/types\"\nimport { getVariableValue } from \"../../animation/utils/css-variables-conversion\"\nimport { isCSSVariableToken } from \"../../animation/utils/is-css-variable\"\nimport { addDomEvent } from \"../../events/add-dom-event\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { frame } from \"../../frameloop/frame\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport {\n convertBoundingBoxToBox,\n convertBoxToBoundingBox,\n} from \"../../projection/geometry/conversion\"\nimport { calcLength } from \"../../projection/geometry/delta-calc\"\nimport { createBox } from \"../../projection/geometry/models\"\nimport type {\n IProjectionNode,\n LayoutUpdateData,\n} from \"../../projection/node/types\"\nimport { eachAxis } from \"../../projection/utils/each-axis\"\nimport { measurePageBox } from \"../../projection/utils/measure\"\nimport type { VisualElement } from \"../../render/VisualElement\"\nimport { resize } from \"../../resize\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { percent, px } from \"../../value/types/numbers/units\"\nimport { addValueToWillChange } from \"../../value/will-change/add-will-change\"\nimport type { PanInfo } from \"../pan/types\"\nimport { PanSession } from \"../pan/PanSession\"\nimport { isElementTextInput } from \"../press/utils/is-keyboard-accessible\"\nimport { setDragLock } from \"./state/set-active\"\nimport type { DragPointConstraint, ResolvedConstraints } from \"./types\"\nimport {\n applyConstraints,\n calcOrigin,\n calcRelativeConstraints,\n calcViewportConstraints,\n defaultElastic,\n rebaseAxisConstraints,\n resolveDragElastic,\n} from \"./utils/constraints\"\n\n/**\n * Re-read the scroll of the projection's ancestors, and return that of the\n * `layoutScroll` ones as a key that changes when any of them scroll.\n *\n * Clear the cached scroll first so `updateScroll` bypasses its\n * per-animationId cache and re-reads the live value.\n */\nfunction measureScroll(projection: IProjectionNode) {\n let key = \"\"\n\n for (const node of projection.path) {\n node.scroll = undefined\n node.updateScroll()\n\n const { scroll } = node as IProjectionNode\n if (node !== projection.root && scroll) {\n key += scroll.offset.x + \",\" + scroll.offset.y + \",\"\n }\n }\n\n return key\n}\n\nexport const elementDragControls = new WeakMap<\n VisualElement,\n VisualElementDragControls\n>()\n\nexport interface DragControlOptions {\n /**\n * This distance after which dragging starts and a direction is locked in.\n *\n * @public\n */\n distanceThreshold?: number\n\n /**\n * Whether to immediately snap to the cursor when dragging starts.\n *\n * @public\n */\n snapToCursor?: boolean\n\n /**\n * Start dragging straight away, rather than once the pointer has moved\n * past `distanceThreshold`. For instance, to carry on a drag from\n * another element.\n *\n * @public\n */\n immediate?: boolean\n}\n\ntype DragDirection = \"x\" | \"y\"\n\nexport class VisualElementDragControls {\n visualElement: VisualElement<HTMLElement>\n\n private panSession?: PanSession\n\n private openDragLock: VoidFunction | null = null\n\n isDragging = false\n private currentDirection: DragDirection | null = null\n\n originPoint: Point = { x: 0, y: 0 }\n\n /**\n * The permitted boundaries of travel, in pixels.\n */\n private constraints: ResolvedConstraints | false = false\n\n private hasMutatedConstraints = false\n\n /**\n * A constraint, from a `dragConstraints` function, that moves the\n * element itself, from the drag's latest pointer position.\n */\n private point?: DragPointConstraint | false\n\n /**\n * The `layoutScroll` ancestors' scroll (see measureScroll) when ref\n * constraints were last measured.\n */\n private scroll?: string\n\n /**\n * The per-axis resolved elastic values.\n */\n elastic = createBox()\n\n /**\n * The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n private latestPointerEvent: PointerEvent | null = null\n\n /**\n * The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n private latestPanInfo: PanInfo | null = null\n\n /**\n * Where drag options are read from. By default these are the\n * VisualElement's props (as with a React `motion` component), but the\n * vanilla `drag()` API provides its own.\n */\n private readProps: () => MotionNodeOptions\n\n constructor(\n visualElement: VisualElement<HTMLElement>,\n readProps: () => MotionNodeOptions = () => visualElement.getProps()\n ) {\n this.visualElement = visualElement\n this.readProps = readProps\n }\n\n start(originEvent: PointerEvent, options: DragControlOptions = {}) {\n /**\n * Don't start dragging if this component is exiting\n */\n if (this.visualElement.presenceContext?.isPresent === false) return\n\n const onSessionStart = (event: PointerEvent) => {\n if (options.snapToCursor) this.snapToCursor(event)\n this.stopAnimation()\n }\n\n const onStart = (event: PointerEvent, info: PanInfo) => {\n // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n const { drag, dragConstraints, dragPropagation, onDragStart } =\n this.getProps()\n\n if (drag && !dragPropagation) {\n this.openDragLock?.()\n\n this.openDragLock = setDragLock(drag)\n\n // If we don 't have the lock, don't start dragging\n if (!this.openDragLock) return\n }\n\n this.latestPointerEvent = event\n this.latestPanInfo = info\n this.isDragging = true\n\n this.currentDirection = null\n\n this.resolveConstraints()\n\n const { projection } = this.visualElement\n if (projection) {\n projection.isAnimationBlocked = true\n projection.target = undefined\n }\n\n /**\n * Record gesture origin and pointer offset\n */\n eachAxis((axis) => {\n let current = this.getAxisMotionValue(axis).get() || 0\n\n /**\n * If the MotionValue is a CSS variable, like \"var(--y)\",\n * resolve it so it can be converted to px below.\n */\n if (isCSSVariableToken(current)) {\n current =\n getVariableValue(\n current,\n this.visualElement.current!\n ) || 0\n }\n\n /**\n * If the MotionValue is a px or percentage value convert to px\n */\n if (px.test(current)) {\n current = parseFloat(current)\n } else if (percent.test(current)) {\n const measuredAxis = projection?.layout?.layoutBox[axis]\n\n if (measuredAxis) {\n current =\n calcLength(measuredAxis) *\n (parseFloat(current) / 100)\n }\n }\n\n this.originPoint[axis] = current\n })\n\n this.point =\n typeof dragConstraints === \"function\" && dragConstraints(this)\n\n // Fire onDragStart event\n if (onDragStart) {\n frame.update(() => onDragStart(event, info), false, true)\n }\n\n addValueToWillChange(this.visualElement, \"transform\")\n\n this.visualElement.animationState?.setActive(\"whileDrag\", true)\n }\n\n const onMove = (event: PointerEvent, info: PanInfo) => {\n this.latestPointerEvent = event\n this.latestPanInfo = info\n\n const {\n dragPropagation,\n dragDirectionLock,\n onDirectionLock,\n onDrag,\n } = this.getProps()\n\n // If we didn't successfully receive the gesture lock, early return.\n if (!dragPropagation && !this.openDragLock) return\n\n const { offset } = info\n // Attempt to detect drag direction if directionLock is true\n if (dragDirectionLock && this.currentDirection === null) {\n this.currentDirection = getCurrentDirection(offset)\n\n /**\n * Wait for more movement until a direction is set. Once\n * it is, apply this move too: it can be the last before\n * release when the browser coalesces a fast gesture.\n */\n if (this.currentDirection === null) return\n\n onDirectionLock && onDirectionLock(this.currentDirection)\n }\n\n // Update each point with the latest position\n this.updateAxis(\"x\", offset)\n this.updateAxis(\"y\", offset)\n this.point && this.point.move()\n\n /**\n * Ideally we would leave the renderer to fire naturally at the end of\n * this frame but if the element is about to change layout as the result\n * of a re-render we want to ensure the browser can read the latest\n * bounding box to ensure the pointer and element don't fall out of sync.\n */\n this.visualElement.render()\n\n /**\n * This must fire after the render call as it might trigger a state\n * change which itself might trigger a layout update.\n */\n if (onDrag) {\n frame.update(() => onDrag(event, info), false, true)\n }\n }\n\n const onSessionEnd = (event: PointerEvent, info: PanInfo) => {\n this.latestPointerEvent = event\n this.latestPanInfo = info\n\n this.stop(event, info)\n\n this.latestPointerEvent = null\n this.latestPanInfo = null\n }\n\n const resumeAnimation = () => {\n const { dragSnapToOrigin: snap } = this.getProps()\n if (snap || this.constraints || this.point) {\n this.startAnimation({ x: 0, y: 0 })\n }\n }\n\n const { dragSnapToOrigin } = this.getProps()\n this.panSession = new PanSession(\n originEvent,\n {\n onSessionStart,\n onStart,\n onMove,\n onSessionEnd,\n resumeAnimation,\n },\n {\n ...options,\n transformPagePoint: this.visualElement.getTransformPagePoint(),\n dragSnapToOrigin,\n contextWindow:\n this.visualElement.current?.ownerDocument.defaultView,\n element: this.visualElement.current,\n }\n )\n }\n\n /**\n * @param dragAxes - The axes to animate on release, if not the `drag`\n * prop's, e.g. when drag was disabled mid-gesture.\n */\n stop(\n event?: PointerEvent,\n panInfo?: PanInfo,\n dragAxes?: MotionNodeOptions[\"drag\"]\n ) {\n const finalEvent = event || this.latestPointerEvent\n const finalPanInfo = panInfo || this.latestPanInfo\n\n const isDragging = this.isDragging\n this.cancel()\n if (!isDragging || !finalPanInfo || !finalEvent) return\n\n const { velocity } = finalPanInfo\n this.startAnimation(velocity, dragAxes)\n\n const { onDragEnd } = this.getProps()\n if (onDragEnd) {\n frame.postRender(() => onDragEnd(finalEvent, finalPanInfo))\n }\n }\n\n cancel() {\n this.isDragging = false\n\n const { projection, animationState } = this.visualElement\n\n if (projection) {\n projection.isAnimationBlocked = false\n }\n\n this.endPanSession()\n\n if (!this.getProps().dragPropagation && this.openDragLock) {\n this.openDragLock()\n this.openDragLock = null\n }\n\n animationState?.setActive(\"whileDrag\", false)\n }\n\n /**\n * Clean up the pan session without modifying other drag state.\n * This is used during unmount to ensure event listeners are removed\n * without affecting projection animations or drag locks.\n */\n endPanSession() {\n this.panSession?.end()\n this.panSession = undefined\n }\n\n private updateAxis(axis: DragDirection, offset?: Point) {\n /**\n * Read drag per axis: a callback fired while updating the x axis\n * can synchronously re-render with new props.\n */\n const { drag } = this.readProps()\n\n // If we're not dragging this axis, do an early return.\n if (!offset || !shouldDrag(axis, drag, this.currentDirection)) return\n\n const axisValue = this.getAxisMotionValue(axis)\n let next = this.originPoint[axis] + offset[axis]\n\n // Apply constraints\n const constraints = this.constraints && this.constraints[axis]\n if (constraints) {\n next = applyConstraints(next, constraints, this.elastic[axis])\n }\n\n this.point ? (this.point[axis] = next) : axisValue.set(next)\n }\n\n private resolveConstraints() {\n const { dragConstraints, dragElastic } = this.getProps()\n\n const { projection } = this.visualElement\n const layout =\n projection && (projection.layout || projection.measure(false))\n\n const prevConstraints = this.constraints\n\n if (isElementConstraints(dragConstraints)) {\n /**\n * Ref constraints are measured with the layout. Scrolling a\n * `layoutScroll` ancestor since can move the element relative\n * to them without a layout measurement, so measure them again\n * (#2024). Otherwise keep them: they and the layout can both\n * have moved on the page since, e.g. when content above grows.\n */\n if (\n !this.constraints ||\n this.scroll !== measureScroll(projection!)\n ) {\n this.constraints = this.resolveRefConstraints()\n }\n } else {\n if (\n dragConstraints &&\n layout &&\n typeof dragConstraints === \"object\"\n ) {\n this.constraints = calcRelativeConstraints(\n layout.layoutBox,\n dragConstraints\n )\n } else {\n this.constraints = false\n }\n }\n\n this.elastic = resolveDragElastic(dragElastic)\n\n /**\n * If we're outputting to external MotionValues, we want to rebase the measured constraints\n * from viewport-relative to component-relative. This only applies to relative (non-ref)\n * constraints, as ref-based constraints from calcViewportConstraints are already in the\n * correct coordinate space for the motion value transform offset.\n */\n if (\n prevConstraints !== this.constraints &&\n !isElementConstraints(dragConstraints) &&\n layout &&\n this.constraints &&\n !this.hasMutatedConstraints\n ) {\n eachAxis((axis) => {\n if (\n this.constraints !== false &&\n this.getAxisMotionValue(axis)\n ) {\n this.constraints[axis] = rebaseAxisConstraints(\n layout.layoutBox[axis],\n this.constraints[axis]\n )\n }\n })\n }\n }\n\n private resolveRefConstraints() {\n const { dragConstraints: constraints, onMeasureDragConstraints } =\n this.getProps()\n if (!isElementConstraints(constraints)) return false\n\n const constraintsElement = resolveConstraintsElement(constraints)\n\n process.env.NODE_ENV !== \"production\" &&\n invariant(\n !!constraintsElement,\n \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\",\n \"drag-constraints-ref\"\n )\n\n const { projection } = this.visualElement\n\n // TODO\n if (!projection || !projection.layout) return false\n\n /**\n * Refresh the scroll offsets of the root and `layoutScroll`\n * ancestors so the constraint's viewport box translates to the\n * layout's coordinates. The scroll captured when the layout was\n * measured can be stale if they've scrolled since — e.g. via the\n * browser restoring scroll on refresh, or an ancestor layout effect\n * running after this element's mount (#2829).\n */\n this.scroll = measureScroll(projection)\n\n const constraintsBox = measurePageBox(\n constraintsElement as HTMLElement,\n projection.root!,\n this.visualElement.getTransformPagePoint()\n )\n\n /**\n * layoutBox removes the scroll of `layoutScroll` ancestors, so\n * remove it from the constraints box too.\n */\n let measuredConstraints = calcViewportConstraints(\n projection.layout.layoutBox,\n projection.removeElementScroll(constraintsBox)\n )\n\n /**\n * If there's an onMeasureDragConstraints listener we call it and\n * if different constraints are returned, set constraints to that\n */\n if (onMeasureDragConstraints) {\n const userConstraints = onMeasureDragConstraints(\n convertBoxToBoundingBox(measuredConstraints)\n )\n\n this.hasMutatedConstraints = !!userConstraints\n\n if (userConstraints) {\n measuredConstraints = convertBoundingBoxToBox(userConstraints)\n }\n }\n\n return measuredConstraints\n }\n\n private startAnimation(\n velocity: Point,\n dragAxes?: MotionNodeOptions[\"drag\"]\n ) {\n const {\n drag,\n dragMomentum,\n dragElastic,\n dragTransition,\n dragSnapToOrigin,\n onDragTransitionEnd,\n } = this.getProps()\n\n /**\n * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n * of spring animations so we should look into adding a disable spring option to `inertia`.\n * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n * using the value of `dragElastic`.\n */\n const options = {\n bounceStiffness: dragElastic ? 200 : 1000000,\n bounceDamping: dragElastic ? 40 : 10000000,\n timeConstant: 750,\n restDelta: 1,\n restSpeed: 10,\n ...dragTransition,\n }\n\n const axisVelocity = (axis: DragDirection) =>\n dragMomentum &&\n !(this.point && dragSnapToOrigin) &&\n shouldDrag(axis, dragAxes || drag, this.currentDirection)\n ? velocity[axis]\n : 0\n\n if (this.point && !dragSnapToOrigin) {\n return this.point\n .release(\n { x: axisVelocity(\"x\"), y: axisVelocity(\"y\") },\n options\n )\n .then(onDragTransitionEnd)\n }\n\n const constraints: Partial<ResolvedConstraints> = this.constraints || {}\n\n const momentumAnimations = eachAxis((axis) => {\n if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {\n return\n }\n\n let transition = constraints[axis] || {}\n\n if (\n dragSnapToOrigin === true ||\n (dragSnapToOrigin as unknown) === axis\n )\n transition = { min: 0, max: 0 }\n\n const inertia: Transition = {\n type: \"inertia\",\n velocity: axisVelocity(axis),\n ...options,\n ...transition,\n }\n\n // If we're not animating on an externally-provided `MotionValue` we can use the\n // component's animation controls which will handle interactions with whileHover (etc),\n // otherwise we just have to animate the `MotionValue` itself.\n return this.startAxisValueAnimation(axis, inertia)\n })\n\n // Run all animations and then resolve the new drag constraints.\n return Promise.all(momentumAnimations).then(onDragTransitionEnd)\n }\n\n private startAxisValueAnimation(\n axis: DragDirection,\n transition: Transition\n ) {\n const axisValue = this.getAxisMotionValue(axis)\n\n addValueToWillChange(this.visualElement, axis)\n\n return axisValue.start(\n animateMotionValue(\n axis,\n axisValue,\n 0,\n transition,\n this.visualElement,\n false\n )\n )\n }\n\n stopAnimation() {\n eachAxis((axis) => this.getAxisMotionValue(axis).stop())\n }\n\n /**\n * Drag works differently depending on which props are provided.\n *\n * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n * - Otherwise, we apply the delta to the x/y motion values.\n */\n getAxisMotionValue(axis: DragDirection) {\n const dragKey =\n `_drag${axis.toUpperCase()}` as `_drag${Uppercase<DragDirection>}`\n const props = this.readProps()\n const externalMotionValue = props[dragKey]\n\n return externalMotionValue\n ? externalMotionValue\n : this.visualElement.getValue(\n axis,\n this.visualElement.latestValues[axis] ?? 0\n )\n }\n\n /**\n * Measure the live box - projection.layout may or may not include the\n * drag transform, depending on when it was measured.\n */\n private snapToCursor({ clientX, clientY }: PointerEvent) {\n const { drag } = this.getProps()\n const point = { x: clientX, y: clientY }\n const cursor =\n this.visualElement.getTransformPagePoint()?.(point) || point\n const box = this.visualElement.measureViewportBox()\n\n eachAxis((axis) => {\n if (!shouldDrag(axis, drag, this.currentDirection)) return\n\n const axisValue = this.getAxisMotionValue(axis)\n const { min, max } = box[axis]\n\n axisValue.set(\n (axisValue.get() || 0) + cursor[axis] - mixNumber(min, max, 0.5)\n )\n })\n }\n\n /**\n * When the viewport resizes we want to check if the measured constraints\n * have changed and, if so, reposition the element within those new constraints\n * relative to where it was before the resize.\n */\n scalePositionWithinConstraints() {\n if (!this.visualElement.current) return\n\n const { drag, dragConstraints } = this.getProps()\n const { projection } = this.visualElement\n if (\n !isElementConstraints(dragConstraints) ||\n !projection ||\n !this.constraints\n )\n return\n\n /**\n * Stop current animations as there can be visual glitching if we try to do\n * this mid-animation\n */\n this.stopAnimation()\n\n /**\n * Record the relative position of the dragged element relative to the\n * constraints box and save as a progress value.\n */\n const constraints = this.constraints as ResolvedConstraints\n const boxProgress = { x: 0, y: 0 }\n eachAxis((axis) => {\n const latest = this.getAxisMotionValue(axis).get()\n boxProgress[axis] = calcOrigin(\n { min: latest, max: latest },\n constraints[axis] as Axis\n )\n })\n\n /**\n * Update the layout of this element and resolve the latest drag constraints\n */\n const { transformTemplate } = this.visualElement.getProps()\n this.visualElement.current.style.transform = transformTemplate\n ? transformTemplate({}, \"\")\n : \"none\"\n projection.root?.updateScroll()\n projection.updateLayout()\n\n /**\n * Reset constraints so resolveConstraints() will recalculate them\n * with the freshly measured layout rather than returning the cached value.\n */\n this.constraints = false\n this.resolveConstraints()\n\n /**\n * For each axis, calculate the current progress of the layout axis\n * within the new constraints.\n */\n eachAxis((axis) => {\n const axisValue = this.getAxisMotionValue(axis)\n\n /**\n * An element resting at its origin has no offset to preserve,\n * and re-projecting 0 into the new constraints would move it.\n */\n if (!shouldDrag(axis, drag, null) || !axisValue.get()) return\n\n /**\n * Calculate a new transform based on the previous box progress\n */\n const { min, max } = (this.constraints as ResolvedConstraints)[\n axis\n ] as Axis\n axisValue.set(mixNumber(min, max, boxProgress[axis]))\n })\n\n /**\n * Flush the updated transform to the DOM synchronously to prevent\n * a visual flash at the element's CSS layout position (0,0) when\n * the transform was stripped for measurement.\n */\n this.visualElement.render()\n }\n\n addListeners() {\n if (!this.visualElement.current) return\n elementDragControls.set(this.visualElement, this)\n const element = this.visualElement.current\n\n /**\n * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n */\n const stopPointerListener = addPointerEvent(\n element,\n \"pointerdown\",\n (event) => {\n const { drag, dragListener = true } = this.getProps()\n const target = event.target as Element\n\n /**\n * Only block drag if clicking on a text input child element\n * (input, textarea, select, contenteditable) where users might\n * want to select text or interact with the control.\n *\n * Buttons and links don't block drag since they don't have\n * click-and-move actions of their own.\n */\n const isClickingTextInputChild =\n target !== element && isElementTextInput(target)\n\n if (drag && dragListener && !isClickingTextInputChild) {\n this.start(event)\n }\n }\n )\n\n /**\n * If using ref-based constraints, observe both the draggable element\n * and the constraint container for size changes via ResizeObserver.\n * Setup is deferred because dragConstraints.current is null when\n * addListeners first runs (React hasn't committed the ref yet).\n */\n let stopResizeObservers: VoidFunction | undefined\n\n const measureDragConstraints = () => {\n const { dragConstraints } = this.getProps()\n const constraintsElement =\n isElementConstraints(dragConstraints) &&\n resolveConstraintsElement(dragConstraints)\n\n if (constraintsElement) {\n this.constraints = this.resolveRefConstraints()\n\n if (!stopResizeObservers) {\n stopResizeObservers = startResizeObservers(\n element,\n constraintsElement as HTMLElement,\n () => this.scalePositionWithinConstraints()\n )\n }\n }\n }\n\n const { projection } = this.visualElement\n\n const stopMeasureLayoutListener = projection!.addEventListener(\n \"measure\",\n measureDragConstraints\n )\n\n if (!projection!.layout) {\n projection!.root?.updateScroll()\n projection!.updateLayout()\n }\n\n frame.read(measureDragConstraints)\n\n /**\n * Attach a window resize listener to scale the draggable target within its defined\n * constraints as the window resizes.\n */\n const stopResizeListener = addDomEvent(window, \"resize\", () =>\n this.scalePositionWithinConstraints()\n )\n\n /**\n * If the element's layout changes, calculate the delta and apply that to\n * the drag gesture's origin point.\n */\n const stopLayoutUpdateListener = projection!.addEventListener(\n \"didUpdate\",\n (({ delta, hasLayoutChanged }: LayoutUpdateData) => {\n if (this.isDragging && hasLayoutChanged) {\n eachAxis((axis) => {\n /**\n * Only compensate axes this gesture drags. A\n * non-drag axis follows its layout instead, as\n * nothing would ever move it back (e.g. snapping\n * to origin only animates drag axes).\n */\n if (\n !shouldDrag(\n axis,\n this.getProps().drag,\n this.currentDirection\n )\n )\n return\n\n const motionValue = this.getAxisMotionValue(axis)\n this.originPoint[axis] += delta[axis].translate\n motionValue.set(\n motionValue.get() + delta[axis].translate\n )\n })\n\n this.visualElement.render()\n }\n }) as any\n )\n\n return () => {\n stopResizeListener()\n stopPointerListener()\n stopMeasureLayoutListener()\n stopLayoutUpdateListener()\n stopResizeObservers?.()\n }\n }\n\n getProps(): MotionNodeOptions {\n const props = this.readProps()\n const { dragElastic = defaultElastic, dragMomentum = true } = props\n return { ...props, dragElastic, dragMomentum }\n }\n}\n\ntype ConstraintsElement = Element | { current: Element | null }\n\n/**\n * `dragConstraints` can be an element, or a ref (`{ current }`) to one.\n */\nfunction isElementConstraints(\n constraints: MotionNodeOptions[\"dragConstraints\"]\n): constraints is ConstraintsElement {\n return (\n !!constraints &&\n typeof constraints === \"object\" &&\n (\"current\" in constraints || \"nodeType\" in constraints)\n )\n}\n\nconst resolveConstraintsElement = (constraints: ConstraintsElement) =>\n \"current\" in constraints ? constraints.current : constraints\n\nfunction skipFirstCall(callback: VoidFunction): VoidFunction {\n let isFirst = true\n return () => {\n if (isFirst) {\n isFirst = false\n return\n }\n callback()\n }\n}\n\nfunction startResizeObservers(\n element: HTMLElement,\n constraintsElement: HTMLElement,\n onResize: VoidFunction\n): VoidFunction {\n const stopElement = resize(element, skipFirstCall(onResize))\n const stopContainer = resize(constraintsElement, skipFirstCall(onResize))\n return () => {\n stopElement()\n stopContainer()\n }\n}\n\nfunction shouldDrag(\n direction: DragDirection,\n drag: boolean | DragDirection | undefined,\n currentDirection: null | DragDirection\n) {\n return (\n (drag === true || drag === direction) &&\n (currentDirection === null || currentDirection === direction)\n )\n}\n\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(\n offset: Point,\n lockThreshold = 10\n): DragDirection | null {\n let direction: DragDirection | null = null\n\n if (Math.abs(offset.y) > lockThreshold) {\n direction = \"y\"\n } else if (Math.abs(offset.x) > lockThreshold) {\n direction = \"x\"\n }\n\n return direction\n}\n\nexport function expectsResolvedDragConstraints({\n dragConstraints,\n onMeasureDragConstraints,\n}: MotionNodeOptions) {\n return isElementConstraints(dragConstraints) && !!onMeasureDragConstraints\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;AAMG;AACH,SAAS,aAAa,CAAC,UAA2B,EAAA;IAC9C,IAAI,GAAG,GAAG,EAAE;AAEZ,IAAA,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE;AAChC,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS;QACvB,IAAI,CAAC,YAAY,EAAE;AAEnB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAuB;QAC1C,IAAI,IAAI,KAAK,UAAU,CAAC,IAAI,IAAI,MAAM,EAAE;AACpC,YAAA,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG;QACxD;IACJ;AAEA,IAAA,OAAO,GAAG;AACd;AAEO,MAAM,mBAAmB,GAAG,IAAI,OAAO;MAgCjC,yBAAyB,CAAA;IAqDlC,WAAA,CACI,aAAyC,EACzC,SAAA,GAAqC,MAAM,aAAa,CAAC,QAAQ,EAAE,EAAA;QAlD/D,IAAA,CAAA,YAAY,GAAwB,I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C,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE;QACpC,SAAS,GAAG,GAAG;IACnB;SAAO,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE;QAC3C,SAAS,GAAG,GAAG;IACnB;AAEA,IAAA,OAAO,SAAS;AACpB;SAEgB,8BAA8B,CAAC,EAC3C,eAAe,EACf,wBAAwB,GACR,EAAA;IAChB,OAAO,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,wBAAwB;AAC9E;;;;"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { visualElementStore } from '../../render/store.mjs';
|
|
2
2
|
import { activeScope, addToScope } from '../../scope/active.mjs';
|
|
3
|
+
import { motionValue } from '../../value/index.mjs';
|
|
3
4
|
import { resolveElements } from '../../utils/resolve-elements.mjs';
|
|
4
5
|
import { acquireDragNode } from './projection.mjs';
|
|
5
6
|
import { VisualElementDragControls } from './VisualElementDragControls.mjs';
|
|
6
7
|
|
|
7
|
-
const toProps = ({ axis, constraints, elastic, momentum, transition, snapToOrigin, directionLock, propagation, onStart, onMove, onEnd, onDirectionLock, onTransitionEnd, onMeasureConstraints, }) => ({
|
|
8
|
+
const toProps = ({ axis, constraints, elastic, momentum, transition, snapToOrigin, directionLock, propagation, onStart, onMove, onEnd, onDirectionLock, onTransitionEnd, onMeasureConstraints, x, y, }) => ({
|
|
8
9
|
drag: axis || true,
|
|
10
|
+
_dragX: x || (y && motionValue(0)),
|
|
11
|
+
_dragY: y || (x && motionValue(0)),
|
|
9
12
|
dragConstraints: constraints,
|
|
10
13
|
dragElastic: elastic,
|
|
11
14
|
dragMomentum: momentum,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/drag/index.ts"],"sourcesContent":["import type { BoundingBox } from \"motion-utils\"\nimport type { InertiaOptions } from \"../../animation/types\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport { visualElementStore } from \"../../render/store\"\nimport type { VisualElement } from \"../../render/VisualElement\"\nimport { activeScope, addToScope } from \"../../scope/active\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../../utils/resolve-elements\"\nimport { acquireDragNode } from \"./projection\"\nimport type { DragConstraintsFunction, DragElastic, DragHandler } from \"./types\"\nimport { VisualElementDragControls } from \"./VisualElementDragControls\"\n\n/**\n * @public\n */\nexport interface DragOptions {\n /**\n * Restrict dragging to a single axis. By default an element can be\n * dragged on both axes.\n */\n axis?: \"x\" | \"y\"\n\n /**\n * The permitted draggable area. Either `top`/`left`/`right`/`bottom`\n * distances in pixels, relative to the element's origin, an element\n * the draggable element must stay within, or a function that returns\n * a `DragPointConstraint` to move the element itself.\n */\n constraints?: Partial<BoundingBox> | Element | DragConstraintsFunction\n\n /**\n * How far, from `0` to `1`, the element can move outside its\n * constraints. Can be set per edge. Defaults to `0.35`.\n */\n elastic?: DragElastic\n\n /**\n * Whether to carry the gesture's velocity into an inertia animation\n * on release. Defaults to `true`.\n */\n momentum?: boolean\n\n /**\n * Options for the inertia animation that runs on release.\n */\n transition?: InertiaOptions\n\n /**\n * Animate back to the origin on release.\n */\n snapToOrigin?: boolean | \"x\" | \"y\"\n\n /**\n * Lock dragging to the first axis the pointer moves along.\n */\n directionLock?: boolean\n\n /**\n * Allow drag gestures to start on parent elements that are also\n * draggable. By default, only the innermost draggable element moves.\n */\n propagation?: boolean\n\n onStart?: DragHandler\n onMove?: DragHandler\n onEnd?: DragHandler\n onDirectionLock?: (axis: \"x\" | \"y\") => void\n onTransitionEnd?: () => void\n\n /**\n * Called when element constraints are measured. Return a new\n * `BoundingBox` to override them.\n */\n onMeasureConstraints?: (constraints: BoundingBox) => BoundingBox | void\n}\n\nconst toProps = ({\n axis,\n constraints,\n elastic,\n momentum,\n transition,\n snapToOrigin,\n directionLock,\n propagation,\n onStart,\n onMove,\n onEnd,\n onDirectionLock,\n onTransitionEnd,\n onMeasureConstraints,\n}: DragOptions): MotionNodeOptions => ({\n drag: axis || true,\n dragConstraints: constraints,\n dragElastic: elastic,\n dragMomentum: momentum,\n dragTransition: transition,\n dragSnapToOrigin: snapToOrigin,\n dragDirectionLock: directionLock,\n dragPropagation: propagation,\n onDragStart: onStart,\n onDrag: onMove,\n onDragEnd: onEnd,\n onDirectionLock,\n onDragTransitionEnd: onTransitionEnd,\n onMeasureDragConstraints: onMeasureConstraints,\n})\n\nconst dragStyles = [\n \"user-select\",\n \"-webkit-user-select\",\n \"-webkit-touch-callout\",\n \"touch-action\",\n]\n\n/**\n * Apply the styles React's drag prop applies, so touch input drags\n * instead of panning the page, and text selection and native drag (ghost\n * image) don't interrupt the gesture. Returns a function that restores\n * the element's previous values.\n */\nfunction applyDragStyles(element: HTMLElement, axis?: \"x\" | \"y\") {\n const { style } = element\n const draggable = element.getAttribute(\"draggable\")\n const prev = dragStyles.map((key) => style.getPropertyValue(key))\n const touchAction = axis ? \"pan-\" + (axis === \"x\" ? \"y\" : \"x\") : \"none\"\n\n dragStyles.forEach((key, i) =>\n style.setProperty(key, i < 3 ? \"none\" : touchAction)\n )\n element.setAttribute(\"draggable\", \"false\")\n\n return () => {\n dragStyles.forEach((key, i) => style.setProperty(key, prev[i]))\n draggable === null\n ? element.removeAttribute(\"draggable\")\n : element.setAttribute(\"draggable\", draggable)\n }\n}\n\n/**\n * Make elements draggable. Returns a function that removes the gesture.\n *\n * ```javascript\n * const stop = drag(\"#box\", { axis: \"x\", constraints: { left: 0, right: 300 } })\n * ```\n *\n * The element's `x` and `y` are motion values shared with `animate()`\n * and `animateLayout()`, so these can animate the element after a drag.\n *\n * @public\n */\nexport function drag(\n elementOrSelector: ElementOrSelector,\n options: DragOptions = {}\n): VoidFunction {\n const props = toProps(options)\n const scope = activeScope.current\n\n /**\n * Run callbacks in the active scope, so work they start is collected.\n */\n if (scope) {\n for (const key in props) {\n const value = props[key as keyof MotionNodeOptions]\n if (typeof value === \"function\") {\n ;(props as any)[key] = scope.bind(value)\n }\n }\n }\n\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element)\n const [node, release] = acquireDragNode(element as HTMLElement)\n\n /**\n * Measure layout even when not animating it, as constraints and\n * layout-shift correction are computed from it.\n */\n node.setOptions({ alwaysMeasureLayout: true })\n\n const controls = new VisualElementDragControls(\n visualElementStore.get(element) as VisualElement<HTMLElement>,\n () => props\n )\n const removeListeners = controls.addListeners()\n const removeStyles = applyDragStyles(\n element as HTMLElement,\n options.axis\n )\n\n return () => {\n removeStyles()\n removeListeners?.()\n controls.cancel()\n controls.stopAnimation()\n release()\n }\n })\n\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()))\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/drag/index.ts"],"sourcesContent":["import type { BoundingBox } from \"motion-utils\"\nimport type { InertiaOptions } from \"../../animation/types\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport { visualElementStore } from \"../../render/store\"\nimport type { VisualElement } from \"../../render/VisualElement\"\nimport { activeScope, addToScope } from \"../../scope/active\"\nimport { motionValue, type MotionValue } from \"../../value\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../../utils/resolve-elements\"\nimport { acquireDragNode } from \"./projection\"\nimport type { DragConstraintsFunction, DragElastic, DragHandler } from \"./types\"\nimport { VisualElementDragControls } from \"./VisualElementDragControls\"\n\n/**\n * @public\n */\nexport interface DragOptions {\n /**\n * Restrict dragging to a single axis. By default an element can be\n * dragged on both axes.\n */\n axis?: \"x\" | \"y\"\n\n /**\n * The permitted draggable area. Either `top`/`left`/`right`/`bottom`\n * distances in pixels, relative to the element's origin, an element\n * the draggable element must stay within, or a function that returns\n * a `DragPointConstraint` to move the element itself.\n */\n constraints?: Partial<BoundingBox> | Element | DragConstraintsFunction\n\n /**\n * How far, from `0` to `1`, the element can move outside its\n * constraints. Can be set per edge. Defaults to `0.35`.\n */\n elastic?: DragElastic\n\n /**\n * Whether to carry the gesture's velocity into an inertia animation\n * on release. Defaults to `true`.\n */\n momentum?: boolean\n\n /**\n * Options for the inertia animation that runs on release.\n */\n transition?: InertiaOptions\n\n /**\n * Animate back to the origin on release.\n */\n snapToOrigin?: boolean | \"x\" | \"y\"\n\n /**\n * Lock dragging to the first axis the pointer moves along.\n */\n directionLock?: boolean\n\n /**\n * Allow drag gestures to start on parent elements that are also\n * draggable. By default, only the innermost draggable element moves.\n */\n propagation?: boolean\n\n /**\n * Motion values to write the drag to, instead of the element's\n * `x` and `y`. When either is set, the element itself doesn't move,\n * so drag can drive other values, like a dial's rotation.\n *\n * ```javascript\n * const x = motionValue(0)\n * x.on(\"change\", (v) => (dial.style.rotate = v + \"deg\"))\n * drag(dial, { axis: \"x\", x })\n * ```\n */\n x?: MotionValue<number>\n y?: MotionValue<number>\n\n onStart?: DragHandler\n onMove?: DragHandler\n onEnd?: DragHandler\n onDirectionLock?: (axis: \"x\" | \"y\") => void\n onTransitionEnd?: () => void\n\n /**\n * Called when element constraints are measured. Return a new\n * `BoundingBox` to override them.\n */\n onMeasureConstraints?: (constraints: BoundingBox) => BoundingBox | void\n}\n\nconst toProps = ({\n axis,\n constraints,\n elastic,\n momentum,\n transition,\n snapToOrigin,\n directionLock,\n propagation,\n onStart,\n onMove,\n onEnd,\n onDirectionLock,\n onTransitionEnd,\n onMeasureConstraints,\n x,\n y,\n}: DragOptions): MotionNodeOptions => ({\n drag: axis || true,\n _dragX: x || (y && motionValue(0)),\n _dragY: y || (x && motionValue(0)),\n dragConstraints: constraints,\n dragElastic: elastic,\n dragMomentum: momentum,\n dragTransition: transition,\n dragSnapToOrigin: snapToOrigin,\n dragDirectionLock: directionLock,\n dragPropagation: propagation,\n onDragStart: onStart,\n onDrag: onMove,\n onDragEnd: onEnd,\n onDirectionLock,\n onDragTransitionEnd: onTransitionEnd,\n onMeasureDragConstraints: onMeasureConstraints,\n})\n\nconst dragStyles = [\n \"user-select\",\n \"-webkit-user-select\",\n \"-webkit-touch-callout\",\n \"touch-action\",\n]\n\n/**\n * Apply the styles React's drag prop applies, so touch input drags\n * instead of panning the page, and text selection and native drag (ghost\n * image) don't interrupt the gesture. Returns a function that restores\n * the element's previous values.\n */\nfunction applyDragStyles(element: HTMLElement, axis?: \"x\" | \"y\") {\n const { style } = element\n const draggable = element.getAttribute(\"draggable\")\n const prev = dragStyles.map((key) => style.getPropertyValue(key))\n const touchAction = axis ? \"pan-\" + (axis === \"x\" ? \"y\" : \"x\") : \"none\"\n\n dragStyles.forEach((key, i) =>\n style.setProperty(key, i < 3 ? \"none\" : touchAction)\n )\n element.setAttribute(\"draggable\", \"false\")\n\n return () => {\n dragStyles.forEach((key, i) => style.setProperty(key, prev[i]))\n draggable === null\n ? element.removeAttribute(\"draggable\")\n : element.setAttribute(\"draggable\", draggable)\n }\n}\n\n/**\n * Make elements draggable. Returns a function that removes the gesture.\n *\n * ```javascript\n * const stop = drag(\"#box\", { axis: \"x\", constraints: { left: 0, right: 300 } })\n * ```\n *\n * The element's `x` and `y` are motion values shared with `animate()`\n * and `animateLayout()`, so these can animate the element after a drag.\n *\n * @public\n */\nexport function drag(\n elementOrSelector: ElementOrSelector,\n options: DragOptions = {}\n): VoidFunction {\n const props = toProps(options)\n const scope = activeScope.current\n\n /**\n * Run callbacks in the active scope, so work they start is collected.\n */\n if (scope) {\n for (const key in props) {\n const value = props[key as keyof MotionNodeOptions]\n if (typeof value === \"function\") {\n ;(props as any)[key] = scope.bind(value)\n }\n }\n }\n\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element)\n const [node, release] = acquireDragNode(element as HTMLElement)\n\n /**\n * Measure layout even when not animating it, as constraints and\n * layout-shift correction are computed from it.\n */\n node.setOptions({ alwaysMeasureLayout: true })\n\n const controls = new VisualElementDragControls(\n visualElementStore.get(element) as VisualElement<HTMLElement>,\n () => props\n )\n const removeListeners = controls.addListeners()\n const removeStyles = applyDragStyles(\n element as HTMLElement,\n options.axis\n )\n\n return () => {\n removeStyles()\n removeListeners?.()\n controls.cancel()\n controls.stopAnimation()\n release()\n }\n })\n\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()))\n}\n"],"names":[],"mappings":";;;;;;;AA6FA,MAAM,OAAO,GAAG,CAAC,EACb,IAAI,EACJ,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,CAAC,EACD,CAAC,GACS,MAAyB;IACnC,IAAI,EAAE,IAAI,IAAI,IAAI;IAClB,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAClC,IAAA,eAAe,EAAE,WAAW;AAC5B,IAAA,WAAW,EAAE,OAAO;AACpB,IAAA,YAAY,EAAE,QAAQ;AACtB,IAAA,cAAc,EAAE,UAAU;AAC1B,IAAA,gBAAgB,EAAE,YAAY;AAC9B,IAAA,iBAAiB,EAAE,aAAa;AAChC,IAAA,eAAe,EAAE,WAAW;AAC5B,IAAA,WAAW,EAAE,OAAO;AACpB,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,SAAS,EAAE,KAAK;IAChB,eAAe;AACf,IAAA,mBAAmB,EAAE,eAAe;AACpC,IAAA,wBAAwB,EAAE,oBAAoB;AACjD,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG;IACf,aAAa;IACb,qBAAqB;IACrB,uBAAuB;IACvB,cAAc;CACjB;AAED;;;;;AAKG;AACH,SAAS,eAAe,CAAC,OAAoB,EAAE,IAAgB,EAAA;AAC3D,IAAA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO;IACzB,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;AACnD,IAAA,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,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ChE,QAAA,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAe,CAAC,OAAsB,CAAC;AAE/D;;;AAGG;QACH,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC;AAE9C,QAAA,MAAM,QAAQ,GAAG,IAAI,yBAAyB,CAC1C,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAA+B,EAC7D,MAAM,KAAK,CACd;AACD,QAAA,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,EAAE;QAC/C,MAAM,YAAY,GAAG,eAAe,CAChC,OAAsB,EACtB,OAAO,CAAC,IAAI,CACf;AAED,QAAA,OAAO,MAAK;AACR,YAAA,YAAY,EAAE;YACd,eAAe,IAAI;YACnB,QAAQ,CAAC,MAAM,EAAE;YACjB,QAAQ,CAAC,aAAa,EAAE;AACxB,YAAA,OAAO,EAAE;AACb,QAAA,CAAC;AACL,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,UAAU,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;AACrE;;;;"}
|
|
@@ -9,7 +9,7 @@ import { pipe, secondsToMilliseconds, millisecondsToSeconds } from 'motion-utils
|
|
|
9
9
|
|
|
10
10
|
const overflowStyles = /*#__PURE__*/ new Set(["auto", "scroll"]);
|
|
11
11
|
class PanSession {
|
|
12
|
-
constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, element, } = {}) {
|
|
12
|
+
constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, element, immediate, } = {}) {
|
|
13
13
|
this.startEvent = null;
|
|
14
14
|
this.lastMoveEvent = null;
|
|
15
15
|
this.lastMoveEventInfo = null;
|
|
@@ -95,7 +95,7 @@ class PanSession {
|
|
|
95
95
|
this.dragSnapToOrigin = dragSnapToOrigin;
|
|
96
96
|
this.handlers = handlers;
|
|
97
97
|
this.transformPagePoint = transformPagePoint;
|
|
98
|
-
this.distanceThreshold = distanceThreshold;
|
|
98
|
+
this.distanceThreshold = immediate ? 0 : distanceThreshold;
|
|
99
99
|
this.contextWindow = contextWindow || window;
|
|
100
100
|
const info = extractEventInfo(event);
|
|
101
101
|
const initialInfo = transformPoint(info, this.transformPagePoint);
|
|
@@ -119,6 +119,10 @@ class PanSession {
|
|
|
119
119
|
if (element) {
|
|
120
120
|
this.startScrollTracking(element);
|
|
121
121
|
}
|
|
122
|
+
if (immediate) {
|
|
123
|
+
this.handlePointerMove(event, info);
|
|
124
|
+
this.updatePoint();
|
|
125
|
+
}
|
|
122
126
|
}
|
|
123
127
|
/**
|
|
124
128
|
* Start tracking scroll on ancestors and window.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanSession.mjs","sources":["../../../../src/gestures/pan/PanSession.ts"],"sourcesContent":["import { addDomEvent } from \"../../events/add-dom-event\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { extractEventInfo } from \"../../events/event-info\"\nimport { cancelFrame, frame } from \"../../frameloop/frame\"\nimport { time } from \"../../frameloop/sync-time\"\nimport type { EventInfo } from \"../../node/types\"\nimport { distance2D } from \"../../utils/distance\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport type { PanHandler } from \"./types\"\nimport {\n millisecondsToSeconds,\n pipe,\n Point,\n secondsToMilliseconds,\n TransformPoint,\n} from \"motion-utils\"\n\ninterface PanSessionHandlers {\n onSessionStart: PanHandler\n onStart: PanHandler\n onMove: PanHandler\n onEnd: PanHandler\n onSessionEnd: PanHandler\n resumeAnimation: () => void\n}\n\ninterface PanSessionOptions {\n transformPagePoint?: TransformPoint\n dragSnapToOrigin?: boolean | \"x\" | \"y\"\n distanceThreshold?: number\n contextWindow?: (Window & typeof globalThis) | null\n /**\n * Element being dragged. When provided, scroll events on its\n * ancestors and window are compensated so the gesture continues\n * smoothly during scroll.\n */\n element?: HTMLElement | null\n}\n\ninterface TimestampedPoint extends Point {\n timestamp: number\n}\n\nconst overflowStyles = /*#__PURE__*/ new Set([\"auto\", \"scroll\"])\n\nexport class PanSession {\n private history: TimestampedPoint[]\n\n private startEvent: PointerEvent | null = null\n\n private lastMoveEvent: PointerEvent | null = null\n\n private lastMoveEventInfo: EventInfo | null = null\n\n /**\n * Raw (untransformed) event info, re-transformed each frame\n * so transformPagePoint sees the current parent matrix.\n */\n private lastRawMoveEventInfo: EventInfo | null = null\n\n /**\n * Whether a pointermove has arrived since the last updatePoint.\n */\n private hasPendingMove?: boolean\n\n private transformPagePoint?: TransformPoint\n\n private handlers: Partial<PanSessionHandlers> = {}\n\n private removeListeners?: Function\n\n /**\n * For determining if an animation should resume after it is interrupted\n */\n private dragSnapToOrigin: boolean | \"x\" | \"y\"\n\n /**\n * The distance after which panning should start.\n */\n private distanceThreshold: number\n\n private contextWindow: PanSessionOptions[\"contextWindow\"] = window\n\n /**\n * Scroll positions of scrollable ancestors and window.\n */\n private scrollPositions: Map<Element | Window, Point> = new Map()\n\n /**\n * Cleanup function for scroll listeners.\n */\n private removeScrollListeners?: Function\n\n constructor(\n event: PointerEvent,\n handlers: Partial<PanSessionHandlers>,\n {\n transformPagePoint,\n contextWindow = window,\n dragSnapToOrigin = false,\n distanceThreshold = 3,\n element,\n }: PanSessionOptions = {}\n ) {\n // If we have more than one touch, don't start detecting this gesture\n if (!isPrimaryPointer(event)) return\n\n this.dragSnapToOrigin = dragSnapToOrigin\n this.handlers = handlers\n this.transformPagePoint = transformPagePoint\n this.distanceThreshold = distanceThreshold\n this.contextWindow = contextWindow || window\n\n const info = extractEventInfo(event)\n const initialInfo = transformPoint(info, this.transformPagePoint)\n const { point } = initialInfo\n\n /**\n * Stamp the origin with time.now(), not frameData.timestamp: when\n * the frameloop is idle, frameData.timestamp is from the last frame\n * that ran, which can be seconds old, and a fast flick from a\n * standstill would then report near-zero velocity. See #1747.\n */\n this.history = [{ ...point, timestamp: time.now() }]\n\n const { onSessionStart } = handlers\n onSessionStart &&\n onSessionStart(event, getPanInfo(initialInfo, this.history))\n\n // Listen in the capture phase so a descendant calling\n // stopPropagation() (e.g. in its own pointerup handler) can't\n // prevent the gesture from ending. See #2794.\n const eventOptions = { passive: true, capture: true }\n this.removeListeners = pipe(\n addPointerEvent(\n this.contextWindow,\n \"pointermove\",\n this.handlePointerMove,\n eventOptions\n ),\n addPointerEvent(\n this.contextWindow,\n \"pointerup\",\n this.handlePointerUp,\n eventOptions\n ),\n addPointerEvent(\n this.contextWindow,\n \"pointercancel\",\n this.handlePointerUp,\n eventOptions\n )\n )\n\n // Start scroll tracking if element provided\n if (element) {\n this.startScrollTracking(element)\n }\n }\n\n /**\n * Start tracking scroll on ancestors and window.\n */\n private startScrollTracking(element: HTMLElement): void {\n // Store initial scroll positions for scrollable ancestors\n let current = element.parentElement\n while (current) {\n const style = getComputedStyle(current)\n if (\n overflowStyles.has(style.overflowX) ||\n overflowStyles.has(style.overflowY)\n ) {\n this.scrollPositions.set(current, getScroll(current))\n }\n current = current.parentElement\n }\n\n // Track window scroll\n this.scrollPositions.set(window, getScroll(window))\n\n this.removeScrollListeners = pipe(\n // Capture listener catches element scroll events as they bubble\n addDomEvent(window, \"scroll\", this.onElementScroll, {\n capture: true,\n }),\n // Direct window scroll listener (window scroll doesn't bubble)\n addDomEvent(window, \"scroll\", this.onWindowScroll, {})\n )\n }\n\n private onElementScroll = (event: Event): void => {\n this.handleScroll(event.target as Element)\n }\n\n private onWindowScroll = (): void => {\n this.handleScroll(window)\n }\n\n /**\n * Handle scroll compensation during drag.\n *\n * For element scroll: adjusts history origin since pageX/pageY doesn't change.\n * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.\n */\n private handleScroll(target: Element | Window): void {\n const initial = this.scrollPositions.get(target)\n if (!initial) return\n\n const isWindow = target === window\n const current = getScroll(target)\n\n const delta = { x: current.x - initial.x, y: current.y - initial.y }\n if (delta.x === 0 && delta.y === 0) return\n\n if (isWindow) {\n // Window scroll: pageX/pageY changes, so update lastMoveEventInfo\n if (this.lastMoveEventInfo) {\n this.lastMoveEventInfo.point.x += delta.x\n this.lastMoveEventInfo.point.y += delta.y\n }\n } else {\n // Element scroll: pageX/pageY unchanged, so adjust history origin\n if (this.history.length > 0) {\n this.history[0].x -= delta.x\n this.history[0].y -= delta.y\n }\n }\n\n this.scrollPositions.set(target, current)\n frame.update(this.updatePoint, true)\n }\n\n private updatePoint = () => {\n if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return\n this.hasPendingMove = false\n\n // Re-transform raw point through current transformPagePoint so\n // animated parent transforms (e.g. rotation) are picked up each frame\n if (this.lastRawMoveEventInfo) {\n this.lastMoveEventInfo = transformPoint(\n this.lastRawMoveEventInfo,\n this.transformPagePoint\n )\n }\n\n const info = getPanInfo(this.lastMoveEventInfo, this.history)\n const isPanStarted = this.startEvent !== null\n\n // Only start panning if the offset is larger than 3 pixels. If we make it\n // any larger than this we'll want to reset the pointer history\n // on the first update to avoid visual snapping to the cursor.\n const isDistancePastThreshold =\n distance2D(info.offset, { x: 0, y: 0 }) >= this.distanceThreshold\n\n if (!isPanStarted && !isDistancePastThreshold) return\n\n const { point } = info\n this.history.push({ ...point, timestamp: time.now() })\n\n const { onStart, onMove } = this.handlers\n\n if (!isPanStarted) {\n onStart?.(this.lastMoveEvent, info)\n this.startEvent = this.lastMoveEvent\n }\n\n onMove?.(this.lastMoveEvent, info)\n }\n\n private handlePointerMove = (event: PointerEvent, info: EventInfo) => {\n /**\n * This event's pageX/pageY already include any window scroll that\n * hasn't fired its scroll event yet. Settle it now, so that scroll\n * event doesn't add it to the new point a second time.\n */\n this.handleScroll(window)\n\n this.lastMoveEvent = event\n this.lastRawMoveEventInfo = info\n this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint)\n this.hasPendingMove = true\n\n // Throttle mouse move event to once per frame\n frame.update(this.updatePoint, true)\n }\n\n private handlePointerUp = (event: PointerEvent, info: EventInfo) => {\n // Browsers flush a coalesced pointermove immediately before\n // pointerup, so the final move can still be waiting for a frame.\n this.hasPendingMove && this.updatePoint()\n this.end()\n\n const { onEnd, onSessionEnd, resumeAnimation } = this.handlers\n\n // Resume animation if dragSnapToOrigin is set OR if no drag started (user just clicked)\n // This ensures constraint animations continue when interrupted by a click\n if (this.dragSnapToOrigin || !this.startEvent) {\n resumeAnimation?.()\n }\n if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return\n\n const panInfo = getPanInfo(\n event.type === \"pointercancel\"\n ? this.lastMoveEventInfo\n : transformPoint(info, this.transformPagePoint),\n this.history\n )\n\n this.startEvent && onEnd?.(event, panInfo)\n onSessionEnd?.(event, panInfo)\n }\n\n updateHandlers(handlers: Partial<PanSessionHandlers>) {\n this.handlers = handlers\n }\n\n end() {\n this.removeListeners?.()\n this.removeScrollListeners?.()\n this.scrollPositions.clear()\n cancelFrame(this.updatePoint)\n }\n}\n\nconst getScroll = (target: Element | Window): Point =>\n target === window\n ? { x: window.scrollX, y: window.scrollY }\n : {\n x: (target as Element).scrollLeft,\n y: (target as Element).scrollTop,\n }\n\nfunction transformPoint(\n info: EventInfo,\n transformPagePoint?: (point: Point) => Point\n) {\n return transformPagePoint ? { point: transformPagePoint(info.point) } : info\n}\n\nfunction subtractPoint(a: Point, b: Point): Point {\n return { x: a.x - b.x, y: a.y - b.y }\n}\n\nfunction getPanInfo({ point }: EventInfo, history: TimestampedPoint[]) {\n return {\n point,\n delta: subtractPoint(point, lastDevicePoint(history)),\n offset: subtractPoint(point, startDevicePoint(history)),\n velocity: getVelocity(history, 0.1),\n }\n}\n\nfunction startDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n return history[0]\n}\n\nfunction lastDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n return history[history.length - 1]\n}\n\nfunction getVelocity(history: TimestampedPoint[], timeDelta: number): Point {\n if (history.length < 2) {\n return { x: 0, y: 0 }\n }\n\n let i = history.length - 1\n let timestampedPoint: TimestampedPoint | null = null\n const lastPoint = lastDevicePoint(history)\n while (i >= 0) {\n timestampedPoint = history[i]\n if (\n lastPoint.timestamp - timestampedPoint.timestamp >\n secondsToMilliseconds(timeDelta)\n ) {\n break\n }\n i--\n }\n\n if (!timestampedPoint) {\n return { x: 0, y: 0 }\n }\n\n /**\n * If the selected point is the pointer-down origin (history[0]),\n * there are better movement points available, and the time gap\n * is suspiciously large (>2x timeDelta), use the next point instead.\n * This prevents stale pointer-down points from diluting velocity\n * in hold-then-flick gestures.\n */\n if (\n timestampedPoint === history[0] &&\n history.length > 2 &&\n lastPoint.timestamp - timestampedPoint.timestamp >\n secondsToMilliseconds(timeDelta) * 2\n ) {\n timestampedPoint = history[1]\n }\n\n const seconds = millisecondsToSeconds(\n lastPoint.timestamp - timestampedPoint.timestamp\n )\n if (seconds === 0) {\n return { x: 0, y: 0 }\n }\n\n const currentVelocity = {\n x: (lastPoint.x - timestampedPoint.x) / seconds,\n y: (lastPoint.y - timestampedPoint.y) / seconds,\n }\n\n if (currentVelocity.x === Infinity) {\n currentVelocity.x = 0\n }\n if (currentVelocity.y === Infinity) {\n currentVelocity.y = 0\n }\n\n return currentVelocity\n}\n"],"names":[],"mappings":";;;;;;;;;AA2CA,MAAM,cAAc,iBAAiB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;MAEnD,UAAU,CAAA;IAgDnB,WAAA,CACI,KAAmB,EACnB,QAAqC,EACrC,EACI,kBAAkB,EAClB,aAAa,GAAG,MAAM,EACtB,gBAAgB,GAAG,KAAK,EACxB,iBAAiB,GAAG,CAAC,EACrB,OAAO,GAAA,GACY,EAAE,EAAA;QAtDrB,IAAA,CAAA,UAAU,GAAwB,IAAI;QAEtC,IAAA,CAAA,aAAa,GAAwB,IAAI;QAEzC,IAAA,CAAA,iBAAiB,GAAqB,IAAI;AAElD;;;AAGG;QACK,IAAA,CAAA,oBAAoB,GAAqB,IAAI;QAS7C,IAAA,CAAA,QAAQ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AACA,IAAA,IAAI,eAAe,CAAC,CAAC,KAAK,QAAQ,EAAE;AAChC,QAAA,eAAe,CAAC,CAAC,GAAG,CAAC;IACzB;AAEA,IAAA,OAAO,eAAe;AAC1B;;;;"}
|
|
1
|
+
{"version":3,"file":"PanSession.mjs","sources":["../../../../src/gestures/pan/PanSession.ts"],"sourcesContent":["import { addDomEvent } from \"../../events/add-dom-event\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { extractEventInfo } from \"../../events/event-info\"\nimport { cancelFrame, frame } from \"../../frameloop/frame\"\nimport { time } from \"../../frameloop/sync-time\"\nimport type { EventInfo } from \"../../node/types\"\nimport { distance2D } from \"../../utils/distance\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport type { PanHandler } from \"./types\"\nimport {\n millisecondsToSeconds,\n pipe,\n Point,\n secondsToMilliseconds,\n TransformPoint,\n} from \"motion-utils\"\n\ninterface PanSessionHandlers {\n onSessionStart: PanHandler\n onStart: PanHandler\n onMove: PanHandler\n onEnd: PanHandler\n onSessionEnd: PanHandler\n resumeAnimation: () => void\n}\n\ninterface PanSessionOptions {\n transformPagePoint?: TransformPoint\n dragSnapToOrigin?: boolean | \"x\" | \"y\"\n distanceThreshold?: number\n contextWindow?: (Window & typeof globalThis) | null\n /**\n * Element being dragged. When provided, scroll events on its\n * ancestors and window are compensated so the gesture continues\n * smoothly during scroll.\n */\n element?: HTMLElement | null\n /**\n * Start panning from `event` straight away, as if the pointer had moved\n * there, rather than waiting for it to move past `distanceThreshold`.\n */\n immediate?: boolean\n}\n\ninterface TimestampedPoint extends Point {\n timestamp: number\n}\n\nconst overflowStyles = /*#__PURE__*/ new Set([\"auto\", \"scroll\"])\n\nexport class PanSession {\n private history: TimestampedPoint[]\n\n private startEvent: PointerEvent | null = null\n\n private lastMoveEvent: PointerEvent | null = null\n\n private lastMoveEventInfo: EventInfo | null = null\n\n /**\n * Raw (untransformed) event info, re-transformed each frame\n * so transformPagePoint sees the current parent matrix.\n */\n private lastRawMoveEventInfo: EventInfo | null = null\n\n /**\n * Whether a pointermove has arrived since the last updatePoint.\n */\n private hasPendingMove?: boolean\n\n private transformPagePoint?: TransformPoint\n\n private handlers: Partial<PanSessionHandlers> = {}\n\n private removeListeners?: Function\n\n /**\n * For determining if an animation should resume after it is interrupted\n */\n private dragSnapToOrigin: boolean | \"x\" | \"y\"\n\n /**\n * The distance after which panning should start.\n */\n private distanceThreshold: number\n\n private contextWindow: PanSessionOptions[\"contextWindow\"] = window\n\n /**\n * Scroll positions of scrollable ancestors and window.\n */\n private scrollPositions: Map<Element | Window, Point> = new Map()\n\n /**\n * Cleanup function for scroll listeners.\n */\n private removeScrollListeners?: Function\n\n constructor(\n event: PointerEvent,\n handlers: Partial<PanSessionHandlers>,\n {\n transformPagePoint,\n contextWindow = window,\n dragSnapToOrigin = false,\n distanceThreshold = 3,\n element,\n immediate,\n }: PanSessionOptions = {}\n ) {\n // If we have more than one touch, don't start detecting this gesture\n if (!isPrimaryPointer(event)) return\n\n this.dragSnapToOrigin = dragSnapToOrigin\n this.handlers = handlers\n this.transformPagePoint = transformPagePoint\n this.distanceThreshold = immediate ? 0 : distanceThreshold\n this.contextWindow = contextWindow || window\n\n const info = extractEventInfo(event)\n const initialInfo = transformPoint(info, this.transformPagePoint)\n const { point } = initialInfo\n\n /**\n * Stamp the origin with time.now(), not frameData.timestamp: when\n * the frameloop is idle, frameData.timestamp is from the last frame\n * that ran, which can be seconds old, and a fast flick from a\n * standstill would then report near-zero velocity. See #1747.\n */\n this.history = [{ ...point, timestamp: time.now() }]\n\n const { onSessionStart } = handlers\n onSessionStart &&\n onSessionStart(event, getPanInfo(initialInfo, this.history))\n\n // Listen in the capture phase so a descendant calling\n // stopPropagation() (e.g. in its own pointerup handler) can't\n // prevent the gesture from ending. See #2794.\n const eventOptions = { passive: true, capture: true }\n this.removeListeners = pipe(\n addPointerEvent(\n this.contextWindow,\n \"pointermove\",\n this.handlePointerMove,\n eventOptions\n ),\n addPointerEvent(\n this.contextWindow,\n \"pointerup\",\n this.handlePointerUp,\n eventOptions\n ),\n addPointerEvent(\n this.contextWindow,\n \"pointercancel\",\n this.handlePointerUp,\n eventOptions\n )\n )\n\n // Start scroll tracking if element provided\n if (element) {\n this.startScrollTracking(element)\n }\n\n if (immediate) {\n this.handlePointerMove(event, info)\n this.updatePoint()\n }\n }\n\n /**\n * Start tracking scroll on ancestors and window.\n */\n private startScrollTracking(element: HTMLElement): void {\n // Store initial scroll positions for scrollable ancestors\n let current = element.parentElement\n while (current) {\n const style = getComputedStyle(current)\n if (\n overflowStyles.has(style.overflowX) ||\n overflowStyles.has(style.overflowY)\n ) {\n this.scrollPositions.set(current, getScroll(current))\n }\n current = current.parentElement\n }\n\n // Track window scroll\n this.scrollPositions.set(window, getScroll(window))\n\n this.removeScrollListeners = pipe(\n // Capture listener catches element scroll events as they bubble\n addDomEvent(window, \"scroll\", this.onElementScroll, {\n capture: true,\n }),\n // Direct window scroll listener (window scroll doesn't bubble)\n addDomEvent(window, \"scroll\", this.onWindowScroll, {})\n )\n }\n\n private onElementScroll = (event: Event): void => {\n this.handleScroll(event.target as Element)\n }\n\n private onWindowScroll = (): void => {\n this.handleScroll(window)\n }\n\n /**\n * Handle scroll compensation during drag.\n *\n * For element scroll: adjusts history origin since pageX/pageY doesn't change.\n * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.\n */\n private handleScroll(target: Element | Window): void {\n const initial = this.scrollPositions.get(target)\n if (!initial) return\n\n const isWindow = target === window\n const current = getScroll(target)\n\n const delta = { x: current.x - initial.x, y: current.y - initial.y }\n if (delta.x === 0 && delta.y === 0) return\n\n if (isWindow) {\n // Window scroll: pageX/pageY changes, so update lastMoveEventInfo\n if (this.lastMoveEventInfo) {\n this.lastMoveEventInfo.point.x += delta.x\n this.lastMoveEventInfo.point.y += delta.y\n }\n } else {\n // Element scroll: pageX/pageY unchanged, so adjust history origin\n if (this.history.length > 0) {\n this.history[0].x -= delta.x\n this.history[0].y -= delta.y\n }\n }\n\n this.scrollPositions.set(target, current)\n frame.update(this.updatePoint, true)\n }\n\n private updatePoint = () => {\n if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return\n this.hasPendingMove = false\n\n // Re-transform raw point through current transformPagePoint so\n // animated parent transforms (e.g. rotation) are picked up each frame\n if (this.lastRawMoveEventInfo) {\n this.lastMoveEventInfo = transformPoint(\n this.lastRawMoveEventInfo,\n this.transformPagePoint\n )\n }\n\n const info = getPanInfo(this.lastMoveEventInfo, this.history)\n const isPanStarted = this.startEvent !== null\n\n // Only start panning if the offset is larger than 3 pixels. If we make it\n // any larger than this we'll want to reset the pointer history\n // on the first update to avoid visual snapping to the cursor.\n const isDistancePastThreshold =\n distance2D(info.offset, { x: 0, y: 0 }) >= this.distanceThreshold\n\n if (!isPanStarted && !isDistancePastThreshold) return\n\n const { point } = info\n this.history.push({ ...point, timestamp: time.now() })\n\n const { onStart, onMove } = this.handlers\n\n if (!isPanStarted) {\n onStart?.(this.lastMoveEvent, info)\n this.startEvent = this.lastMoveEvent\n }\n\n onMove?.(this.lastMoveEvent, info)\n }\n\n private handlePointerMove = (event: PointerEvent, info: EventInfo) => {\n /**\n * This event's pageX/pageY already include any window scroll that\n * hasn't fired its scroll event yet. Settle it now, so that scroll\n * event doesn't add it to the new point a second time.\n */\n this.handleScroll(window)\n\n this.lastMoveEvent = event\n this.lastRawMoveEventInfo = info\n this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint)\n this.hasPendingMove = true\n\n // Throttle mouse move event to once per frame\n frame.update(this.updatePoint, true)\n }\n\n private handlePointerUp = (event: PointerEvent, info: EventInfo) => {\n // Browsers flush a coalesced pointermove immediately before\n // pointerup, so the final move can still be waiting for a frame.\n this.hasPendingMove && this.updatePoint()\n this.end()\n\n const { onEnd, onSessionEnd, resumeAnimation } = this.handlers\n\n // Resume animation if dragSnapToOrigin is set OR if no drag started (user just clicked)\n // This ensures constraint animations continue when interrupted by a click\n if (this.dragSnapToOrigin || !this.startEvent) {\n resumeAnimation?.()\n }\n if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return\n\n const panInfo = getPanInfo(\n event.type === \"pointercancel\"\n ? this.lastMoveEventInfo\n : transformPoint(info, this.transformPagePoint),\n this.history\n )\n\n this.startEvent && onEnd?.(event, panInfo)\n onSessionEnd?.(event, panInfo)\n }\n\n updateHandlers(handlers: Partial<PanSessionHandlers>) {\n this.handlers = handlers\n }\n\n end() {\n this.removeListeners?.()\n this.removeScrollListeners?.()\n this.scrollPositions.clear()\n cancelFrame(this.updatePoint)\n }\n}\n\nconst getScroll = (target: Element | Window): Point =>\n target === window\n ? { x: window.scrollX, y: window.scrollY }\n : {\n x: (target as Element).scrollLeft,\n y: (target as Element).scrollTop,\n }\n\nfunction transformPoint(\n info: EventInfo,\n transformPagePoint?: (point: Point) => Point\n) {\n return transformPagePoint ? { point: transformPagePoint(info.point) } : info\n}\n\nfunction subtractPoint(a: Point, b: Point): Point {\n return { x: a.x - b.x, y: a.y - b.y }\n}\n\nfunction getPanInfo({ point }: EventInfo, history: TimestampedPoint[]) {\n return {\n point,\n delta: subtractPoint(point, lastDevicePoint(history)),\n offset: subtractPoint(point, startDevicePoint(history)),\n velocity: getVelocity(history, 0.1),\n }\n}\n\nfunction startDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n return history[0]\n}\n\nfunction lastDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n return history[history.length - 1]\n}\n\nfunction getVelocity(history: TimestampedPoint[], timeDelta: number): Point {\n if (history.length < 2) {\n return { x: 0, y: 0 }\n }\n\n let i = history.length - 1\n let timestampedPoint: TimestampedPoint | null = null\n const lastPoint = lastDevicePoint(history)\n while (i >= 0) {\n timestampedPoint = history[i]\n if (\n lastPoint.timestamp - timestampedPoint.timestamp >\n secondsToMilliseconds(timeDelta)\n ) {\n break\n }\n i--\n }\n\n if (!timestampedPoint) {\n return { x: 0, y: 0 }\n }\n\n /**\n * If the selected point is the pointer-down origin (history[0]),\n * there are better movement points available, and the time gap\n * is suspiciously large (>2x timeDelta), use the next point instead.\n * This prevents stale pointer-down points from diluting velocity\n * in hold-then-flick gestures.\n */\n if (\n timestampedPoint === history[0] &&\n history.length > 2 &&\n lastPoint.timestamp - timestampedPoint.timestamp >\n secondsToMilliseconds(timeDelta) * 2\n ) {\n timestampedPoint = history[1]\n }\n\n const seconds = millisecondsToSeconds(\n lastPoint.timestamp - timestampedPoint.timestamp\n )\n if (seconds === 0) {\n return { x: 0, y: 0 }\n }\n\n const currentVelocity = {\n x: (lastPoint.x - timestampedPoint.x) / seconds,\n y: (lastPoint.y - timestampedPoint.y) / seconds,\n }\n\n if (currentVelocity.x === Infinity) {\n currentVelocity.x = 0\n }\n if (currentVelocity.y === Infinity) {\n currentVelocity.y = 0\n }\n\n return currentVelocity\n}\n"],"names":[],"mappings":";;;;;;;;;AAgDA,MAAM,cAAc,iBAAiB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;MAEnD,UAAU,CAAA;IAgDnB,WAAA,CACI,KAAmB,EACnB,QAAqC,EACrC,EACI,kBAAkB,EAClB,aAAa,GAAG,MAAM,EACtB,gBAAgB,GAAG,KAAK,EACxB,iBAAiB,GAAG,CAAC,EACrB,OAAO,EACP,SAAS,GAAA,GACU,EAAE,EAAA;QAvDrB,IAAA,CAAA,UAAU,GAAwB,IAAI;QAEtC,IAAA,CAAA,aAAa,GAAwB,IAAI;QAEzC,IAAA,CAAA,iBAAiB,GAAqB,IAAI;AAElD;;;AAGG;QACK,IAAA,CAAA,oBAAoB,GAAqB,IAAI;QAS7C,IAAA,CAAA,QAAQ,GAAgC,EAAE;QAc1C,IAAA,CAAA,aAAa,GAAuC,MAAM;AAElE;;AAEG;AACK,QAAA,IAAA,CAAA,eAAe,GAAiC,IAAI,GAAG,EAAE;AA8GzD,QAAA,IAAA,CAAA,eAAe,GAAG,CAAC,KAAY,KAAU;AAC7C,YAAA,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAi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