solidjs-motion 0.1.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solidjs-motion",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "An animation library for SolidJS — port of motion/react patterns built on the framework-agnostic motion package",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -309,9 +309,37 @@ export function useMotion(opts: MotionOptions | (() => MotionOptions)): UseMotio
309
309
  return mergeProps(userProps ?? {}, {
310
310
  get style() {
311
311
  const cleaned = stripStyleEntriesOwnedByRegistry(userProps?.style)
312
- if (renderedOnce) return cleaned
312
+
313
+ // Drag-friendly `touch-action` default for any drag-configured
314
+ // element. Without this, the mobile browser arbitrates the
315
+ // gesture as native scroll/zoom and may fire `pointercancel`
316
+ // before motion's own `touch-action` write (inside
317
+ // handlePanStart) can take effect — which would manifest as
318
+ // either a missed drag or a panEnd dispatched with stale
319
+ // offset data. Setting it at render time, before the browser
320
+ // ever sees a pointer event, closes that race.
321
+ //
322
+ // axis "x" → "pan-y" (browser may still scroll the page
323
+ // vertically), axis "y" → "pan-x", otherwise → "none".
324
+ //
325
+ // Goes FIRST in the spread order so user-supplied
326
+ // `style: { touchAction: "auto" }` overrides this default.
327
+ const dragOpts = getOpts().drag
328
+ const dragTouchAction = dragOpts
329
+ ? dragOpts === "x"
330
+ ? "pan-y"
331
+ : dragOpts === "y"
332
+ ? "pan-x"
333
+ : "none"
334
+ : undefined
335
+
336
+ const baseWithDefaults = dragTouchAction
337
+ ? { "touch-action": dragTouchAction, ...cleaned }
338
+ : cleaned
339
+
340
+ if (renderedOnce) return baseWithDefaults
313
341
  const composed = composeFirstPaintStyle(userProps?.style)
314
- return composed ? { ...cleaned, ...composed } : cleaned
342
+ return composed ? { ...baseWithDefaults, ...composed } : baseWithDefaults
315
343
  },
316
344
  ref: mergeRefs(userProps?.ref, motionRef),
317
345
  ...(wroteFirstPaintStyle ? { "data-motion-hydrated": "" } : {}),