@micromag/viewer 0.4.21 → 0.4.23

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.
Files changed (2) hide show
  1. package/es/index.js +36 -5
  2. package/package.json +10 -10
package/es/index.js CHANGED
@@ -21,7 +21,7 @@ import { Label, CloseIcon, ScreenPreview, Screen, ArrowIcon, Button as Button$1,
21
21
  import { getStyleFromColor, easings, getStyleFromText, getColorAsString, getDeviceScreens } from '@micromag/core/utils';
22
22
  import { ShareIncentive } from '@micromag/elements/all';
23
23
  import FocusLock from 'react-focus-lock';
24
- import { useSpring } from '@react-spring/core';
24
+ import { useSpringRef, useSpring } from '@react-spring/core';
25
25
  import Scroll from '@micromag/element-scroll';
26
26
  import ShareOptions from '@micromag/element-share-options';
27
27
  import { useGesture } from '@use-gesture/react';
@@ -600,8 +600,14 @@ function ViewerMenuDot(_ref) {
600
600
  primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
601
601
  _ref2$secondary = _ref2.secondary,
602
602
  secondary = _ref2$secondary === void 0 ? 'rgba(255, 255, 255, 0.25)' : _ref2$secondary;
603
+
604
+ // In react-spring v10, useSpring(fn) without deps resets the spring to its initial
605
+ // value on every render via a layout effect. Passing a dummy SpringRef as `ref`
606
+ // prevents this, so our imperative setDotSpringProps.start() calls are not overridden.
607
+ var springRef = useSpringRef();
603
608
  var _useSpring = useSpring(function () {
604
609
  return {
610
+ ref: springRef,
605
611
  scaleX: 0,
606
612
  config: {
607
613
  tension: 200,
@@ -2897,6 +2903,34 @@ function Viewer(_ref) {
2897
2903
  progressSpring = _useDragProgress.progress,
2898
2904
  dragContentBind = _useDragProgress.bind,
2899
2905
  transitionDirection = _useDragProgress.direction;
2906
+
2907
+ // Wrap gesture bindings to skip events from clickable elements (buttons, links, inputs).
2908
+ // Without this, @use-gesture captures pointer events at the document level, preventing
2909
+ // native click events from firing on interactive elements inside screens on mobile Safari.
2910
+ var clickableAwareBindings = useMemo(function () {
2911
+ var bindings = dragContentBind({
2912
+ playing: playing,
2913
+ longPressPaused: longPressPaused
2914
+ });
2915
+ var wrapped = {};
2916
+ var _loop = function _loop() {
2917
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2918
+ key = _Object$entries$_i[0],
2919
+ value = _Object$entries$_i[1];
2920
+ if (typeof value === 'function') {
2921
+ wrapped[key] = function (e) {
2922
+ if (checkClickable(e.target)) return;
2923
+ return value(e);
2924
+ };
2925
+ } else {
2926
+ wrapped[key] = value;
2927
+ }
2928
+ };
2929
+ for (var _i = 0, _Object$entries = Object.entries(bindings); _i < _Object$entries.length; _i++) {
2930
+ _loop();
2931
+ }
2932
+ return wrapped;
2933
+ }, [dragContentBind, playing, longPressPaused]);
2900
2934
  var getScreenStylesByIndex = function getScreenStylesByIndex(index, spring) {
2901
2935
  if (transitionType === 'stack') {
2902
2936
  return {
@@ -3220,10 +3254,7 @@ function Viewer(_ref) {
3220
3254
  refDots: menuDotsContainerRef
3221
3255
  }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", Object.assign({
3222
3256
  className: styles$7.content
3223
- }, dragContentBind({
3224
- playing: playing,
3225
- longPressPaused: longPressPaused
3226
- })), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
3257
+ }, clickableAwareBindings), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
3227
3258
  direction: "previous",
3228
3259
  className: classNames([styles$7.navButton, styles$7.previous]),
3229
3260
  onClick: gotoPreviousScreen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/viewer",
3
- "version": "0.4.21",
3
+ "version": "0.4.23",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -62,14 +62,14 @@
62
62
  "dependencies": {
63
63
  "@babel/runtime": "^7.28.6",
64
64
  "@folklore/routes": "^0.2.36",
65
- "@micromag/core": "^0.4.21",
66
- "@micromag/element-badge": "^0.4.21",
67
- "@micromag/element-scroll": "^0.4.21",
68
- "@micromag/element-share-options": "^0.4.21",
69
- "@micromag/element-webview": "^0.4.21",
70
- "@micromag/elements": "^0.4.21",
71
- "@micromag/intl": "^0.4.21",
72
- "@micromag/screens": "^0.4.21",
65
+ "@micromag/core": "^0.4.23",
66
+ "@micromag/element-badge": "^0.4.23",
67
+ "@micromag/element-scroll": "^0.4.23",
68
+ "@micromag/element-share-options": "^0.4.23",
69
+ "@micromag/element-webview": "^0.4.23",
70
+ "@micromag/elements": "^0.4.23",
71
+ "@micromag/intl": "^0.4.23",
72
+ "@micromag/screens": "^0.4.23",
73
73
  "@react-spring/core": "^10.0.3",
74
74
  "@react-spring/web": "^10.0.3",
75
75
  "@use-gesture/react": "^10.3.0",
@@ -88,6 +88,6 @@
88
88
  "access": "public",
89
89
  "registry": "https://registry.npmjs.org/"
90
90
  },
91
- "gitHead": "34dedbdd988f27c395b838b50dfcd0e48bfa16ee",
91
+ "gitHead": "57c581f5e1758b3d28152f68166cab0468670b92",
92
92
  "types": "es/index.d.ts"
93
93
  }