@micromag/screen-keypad 0.4.58 → 0.4.59

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 +18 -18
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -135,9 +135,9 @@ function KeypadScreen(_ref) {
135
135
  _useDimensionObserver4 = _useDimensionObserver3.height,
136
136
  footerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
137
137
  var _useState = useState(false),
138
- _useState2 = _slicedToArray(_useState, 2),
139
- popupDragDisabled = _useState2[0],
140
- setPopupDragDisabled = _useState2[1];
138
+ _useState2 = _slicedToArray(_useState, 2);
139
+ _useState2[0];
140
+ var setPopupDragDisabled = _useState2[1];
141
141
  var backgroundPlaying = current && (isView || isEdit) && (isCurrentMedia || !isView);
142
142
  var mediaShouldLoad = !isPlaceholder && (current || preload);
143
143
  var isInteractivePreview = isEdit && screenState === null;
@@ -310,19 +310,22 @@ function KeypadScreen(_ref) {
310
310
  }
311
311
  }, [height]);
312
312
  var computePopupProgress = useCallback(function (_ref14) {
313
- var dragActive = _ref14.active,
313
+ var _ref14$active = _ref14.active,
314
+ dragActive = _ref14$active === void 0 ? false : _ref14$active,
314
315
  _ref14$movement = _slicedToArray(_ref14.movement, 2),
315
- my = _ref14$movement[1],
316
+ _ref14$movement$ = _ref14$movement[1],
317
+ my = _ref14$movement$ === void 0 ? null : _ref14$movement$,
316
318
  _ref14$velocity = _slicedToArray(_ref14.velocity, 2),
317
- vy = _ref14$velocity[1];
319
+ _ref14$velocity$ = _ref14$velocity[1],
320
+ vy = _ref14$velocity$ === void 0 ? null : _ref14$velocity$;
318
321
  var damper = 0.5;
319
322
  var windowHeight = typeof window !== 'undefined' ? window.innerHeight : 0;
320
- var delta = windowHeight > 0 ? Math.abs(my) / windowHeight : 0;
321
- var reachedThreshold = vy > 1 || delta > 0.3;
323
+ var delta = windowHeight > 0 && my !== null ? Math.abs(my) / windowHeight : 0;
324
+ var reachedThreshold = vy !== null ? vy > 1 || delta > 0.3 : false;
322
325
  var progress = 0;
323
- if (popupDragDirection === 'top' && my < 0) {
326
+ if (popupDragDirection === 'top' && my !== null && my < 0) {
324
327
  progress = delta * damper * -1;
325
- } else if (popupDragDirection === 'bottom' && my > 0) {
328
+ } else if (popupDragDirection === 'bottom' && my !== null && my > 0) {
326
329
  progress = delta * damper;
327
330
  }
328
331
  if (!dragActive) {
@@ -340,7 +343,7 @@ function KeypadScreen(_ref) {
340
343
  } else {
341
344
  enableInteraction();
342
345
  }
343
- }, [showPopup]);
346
+ }, [showPopup, enableInteraction, disableInteraction]);
344
347
  useEffect(function () {
345
348
  function handleClickOutside(e) {
346
349
  if (!current && isView || popupInnerRef.current && !popupInnerRef.current.contains(e.target) && containerRef.current && containerRef.current.contains(e.target) && !isInteractivePreview && !isEdit && showPopup) {
@@ -374,7 +377,8 @@ function KeypadScreen(_ref) {
374
377
  }, [onCloseModal, showPopup]);
375
378
  var onResolve = useCallback(function () {}, []);
376
379
  var _useDragProgress = useDragProgress({
377
- disabled: !isView || popupDragDisabled,
380
+ disabled: true,
381
+ // !isView || popupDragDisabled, // TODO: remove drag/popupDragDisabled if we're cool with it
378
382
  progress: showPopup ? 0 : 1,
379
383
  computeProgress: computePopupProgress,
380
384
  onResolve: onResolve,
@@ -479,7 +483,7 @@ function KeypadScreen(_ref) {
479
483
  }, [items, screenState, buttonBoxStyle, buttonTextStyle, buttonLayout, isNotInteractive]);
480
484
  useEffect(function () {
481
485
  if (screenState === 'popup' && isPlaceholder) {
482
- setPopup(placeholderPopupBoxStyles); // @note force placeholder
486
+ setPopup(placeholderPopupBoxStyles);
483
487
  setShowPopup(true);
484
488
  }
485
489
  if (screenState === 'keypad') {
@@ -501,13 +505,9 @@ function KeypadScreen(_ref) {
501
505
  // Clear popup contents after close transition completes
502
506
  useEffect(function () {
503
507
  if (isView && screenState === null && !showPopup && !popupTransitioning) {
504
- // console.log('clear popup');
505
508
  setPopup(null);
506
509
  }
507
510
  }, [isView, screenState, showPopup, popupTransitioning]);
508
-
509
- // console.log('render keypad', { screenState, popup, showPopup, popupTransitioning });
510
-
511
511
  return /*#__PURE__*/jsxs("div", {
512
512
  ref: containerRef,
513
513
  className: classNames([styles.container, className, _defineProperty(_defineProperty({}, styles.isPlaceholder, isPlaceholder), styles.withSquareItems, withSquareItems)]),
@@ -717,7 +717,7 @@ function KeypadScreen(_ref) {
717
717
  })
718
718
  })
719
719
  }))]
720
- }) ]
720
+ })]
721
721
  }), !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
722
722
  ref: footerRef,
723
723
  className: styles.footer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-keypad",
3
- "version": "0.4.58",
3
+ "version": "0.4.59",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -94,6 +94,6 @@
94
94
  "access": "public",
95
95
  "registry": "https://registry.npmjs.org/"
96
96
  },
97
- "gitHead": "b521da8b8c3efd5c099079ca3bd6e679b97155cf",
97
+ "gitHead": "e4dfd331721492c90cb0f38b3a60e91237ca990f",
98
98
  "types": "es/index.d.ts"
99
99
  }