solidjs-motion 0.1.3 → 0.1.5
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/CHANGELOG.md +48 -0
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/src/motion-proxy.d.ts +1 -1
- package/dist/src/types.d.ts +14 -0
- package/package.json +1 -1
- package/src/motion-proxy.tsx +2 -0
- package/src/primitives/createDrag.ts +20 -9
- package/src/types.ts +14 -0
- package/src/use-motion.tsx +30 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,54 @@ All notable changes to `solidjs-motion` / `@solidjs-motion/motion` are documente
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.5] — 2026-05-21
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Drag now sets `touch-action` upfront on the element** when `drag` is
|
|
13
|
+
configured, not just inside `handlePanStart` after threshold cross.
|
|
14
|
+
Previously, on mobile, the browser would arbitrate the gesture as
|
|
15
|
+
native scroll/zoom and fire `pointercancel` before motion's own
|
|
16
|
+
touch-action write could take effect — manifesting as missed drags
|
|
17
|
+
or, when the user's `onDragEnd` made a threshold-based decision off
|
|
18
|
+
stale `info.offset`, an immediate dismiss-on-touch (visible in the
|
|
19
|
+
swipe-stack demo: every press fired a left-swipe).
|
|
20
|
+
|
|
21
|
+
Axis mapping mirrors motion-react:
|
|
22
|
+
- `drag="x"` → `touch-action: pan-y` (browser keeps vertical scroll)
|
|
23
|
+
- `drag="y"` → `touch-action: pan-x`
|
|
24
|
+
- `drag={true}` → `touch-action: none`
|
|
25
|
+
|
|
26
|
+
User-supplied `style.touch-action` still overrides via natural
|
|
27
|
+
spread precedence — e.g., `style={{ touchAction: "auto" }}` opts back
|
|
28
|
+
into the browser's default arbitration. Three regression tests added.
|
|
29
|
+
|
|
30
|
+
Removes the need for users to remember to set `touch-action: none` on
|
|
31
|
+
every draggable element — `<motion.div drag="x">` now Just Works on
|
|
32
|
+
touch devices.
|
|
33
|
+
|
|
34
|
+
## [0.1.4] — 2026-05-21
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- **`dragListener` option** on `useMotion` / `<motion.X>` / `motion.create`.
|
|
39
|
+
Mirrors motion-react's prop. Defaults to `true`. When set to `false`,
|
|
40
|
+
drag skips attaching its own pointerdown listener to the element —
|
|
41
|
+
drag becomes external-only, triggered through `dragControls.start(e)`
|
|
42
|
+
from a handle elsewhere. The canonical case is a scrollable drawer
|
|
43
|
+
body where direct pointer interaction must stay scroll-only, and a
|
|
44
|
+
dedicated edge handle is the single drag affordance.
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
const controls = createDragControls()
|
|
48
|
+
return (
|
|
49
|
+
<motion.aside drag="x" dragControls={controls} dragListener={false}>
|
|
50
|
+
{/* body stays scrollable — no drag from direct touch */}
|
|
51
|
+
<span onPointerDown={(e) => controls.start(e)}>handle</span>
|
|
52
|
+
</motion.aside>
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
8
56
|
## [0.1.3] — 2026-05-21
|
|
9
57
|
|
|
10
58
|
### Fixed
|
package/dist/index.js
CHANGED
|
@@ -1246,7 +1246,7 @@ function createDrag(el, getOpts, setActive) {
|
|
|
1246
1246
|
sessionBounds = null;
|
|
1247
1247
|
getOpts().onDragEnd?.(event, info);
|
|
1248
1248
|
};
|
|
1249
|
-
createPan(() => el, () => ({
|
|
1249
|
+
if (getOpts().dragListener !== false) createPan(() => el, () => ({
|
|
1250
1250
|
threshold: getOpts().panThreshold,
|
|
1251
1251
|
onPanStart: handlePanStart,
|
|
1252
1252
|
onPan: handlePan,
|
|
@@ -2308,12 +2308,18 @@ function useMotion(opts) {
|
|
|
2308
2308
|
return mergeProps$1(userProps ?? {}, {
|
|
2309
2309
|
get style() {
|
|
2310
2310
|
const cleaned = stripStyleEntriesOwnedByRegistry(userProps?.style);
|
|
2311
|
-
|
|
2311
|
+
const dragOpts = getOpts().drag;
|
|
2312
|
+
const dragTouchAction = dragOpts ? dragOpts === "x" ? "pan-y" : dragOpts === "y" ? "pan-x" : "none" : void 0;
|
|
2313
|
+
const baseWithDefaults = dragTouchAction ? {
|
|
2314
|
+
"touch-action": dragTouchAction,
|
|
2315
|
+
...cleaned
|
|
2316
|
+
} : cleaned;
|
|
2317
|
+
if (renderedOnce) return baseWithDefaults;
|
|
2312
2318
|
const composed = composeFirstPaintStyle(userProps?.style);
|
|
2313
2319
|
return composed ? {
|
|
2314
|
-
...
|
|
2320
|
+
...baseWithDefaults,
|
|
2315
2321
|
...composed
|
|
2316
|
-
} :
|
|
2322
|
+
} : baseWithDefaults;
|
|
2317
2323
|
},
|
|
2318
2324
|
ref: mergeRefs(userProps?.ref, motionRef),
|
|
2319
2325
|
...wroteFirstPaintStyle ? { "data-motion-hydrated": "" } : {}
|
|
@@ -2380,6 +2386,7 @@ var MOTION_OPT_KEYS = [
|
|
|
2380
2386
|
"dragTransition",
|
|
2381
2387
|
"dragSnapToOrigin",
|
|
2382
2388
|
"dragControls",
|
|
2389
|
+
"dragListener",
|
|
2383
2390
|
"whileDrag",
|
|
2384
2391
|
"panThreshold",
|
|
2385
2392
|
"variants",
|