yet-another-react-lightbox 3.21.9 → 3.23.0

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/index.d.ts CHANGED
@@ -224,7 +224,7 @@ declare enum SwipeState {
224
224
  ANIMATION = 3
225
225
  }
226
226
 
227
- declare function usePointerSwipe<T extends Element = Element>(subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void, pullUpEnabled: boolean, pullDownEnabled: boolean, onPullStart: () => void, onPullProgress: (offset: number) => void, onPullFinish: (offset: number, duration: number) => void, onPullCancel: (offset: number) => void): void;
227
+ declare function usePointerSwipe<T extends Element = Element>({ disableSwipeNavigation }: ControllerSettings, subscribeSensors: UseSensors<T>["subscribeSensors"], isSwipeValid: (offset: number) => boolean, containerWidth: number, swipeAnimationDuration: number, onSwipeStart: () => void, onSwipeProgress: (offset: number) => void, onSwipeFinish: (offset: number, duration: number) => void, onSwipeCancel: (offset: number) => void, pullUpEnabled: boolean, pullDownEnabled: boolean, onPullStart: () => void, onPullProgress: (offset: number) => void, onPullFinish: (offset: number, duration: number) => void, onPullCancel: (offset: number) => void): void;
228
228
 
229
229
  /**
230
230
  * Prevent default effects of the wheel events:
package/dist/index.js CHANGED
@@ -156,6 +156,7 @@ const LightboxDefaultProps = {
156
156
  closeOnBackdropClick: false,
157
157
  preventDefaultWheelX: true,
158
158
  preventDefaultWheelY: false,
159
+ disableSwipeNavigation: false,
159
160
  },
160
161
  portal: {},
161
162
  noScroll: {
@@ -316,7 +317,7 @@ function reducer(state, action) {
316
317
  const globalIndex = state.globalIndex + increment;
317
318
  const currentIndex = getSlideIndex(globalIndex, slides.length);
318
319
  const currentSlide = getSlideIfPresent(slides, currentIndex);
319
- const animation = increment || action.duration
320
+ const animation = increment || action.duration !== undefined
320
321
  ? {
321
322
  increment,
322
323
  duration: action.duration,
@@ -719,7 +720,7 @@ var Gesture;
719
720
  Gesture[Gesture["PULL"] = 2] = "PULL";
720
721
  })(Gesture || (Gesture = {}));
721
722
  const SWIPE_THRESHOLD = 30;
722
- function usePointerSwipe(subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel, pullUpEnabled, pullDownEnabled, onPullStart, onPullProgress, onPullFinish, onPullCancel) {
723
+ function usePointerSwipe({ disableSwipeNavigation }, subscribeSensors, isSwipeValid, containerWidth, swipeAnimationDuration, onSwipeStart, onSwipeProgress, onSwipeFinish, onSwipeCancel, pullUpEnabled, pullDownEnabled, onPullStart, onPullProgress, onPullFinish, onPullCancel) {
723
724
  const offset = React.useRef(0);
724
725
  const pointers = React.useRef([]);
725
726
  const activePointer = React.useRef(undefined);
@@ -791,8 +792,10 @@ function usePointerSwipe(subscribeSensors, isSwipeValid, containerWidth, swipeAn
791
792
  gesture.current = newGesture;
792
793
  };
793
794
  if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > SWIPE_THRESHOLD && isSwipeValid(deltaX)) {
794
- startGesture(Gesture.SWIPE);
795
- onSwipeStart();
795
+ if (!disableSwipeNavigation) {
796
+ startGesture(Gesture.SWIPE);
797
+ onSwipeStart();
798
+ }
796
799
  }
797
800
  else if (Math.abs(deltaY) > Math.abs(deltaX) && exceedsPullThreshold(deltaY, SWIPE_THRESHOLD)) {
798
801
  startGesture(Gesture.PULL);
@@ -1145,7 +1148,7 @@ function Controller({ children, ...props }) {
1145
1148
  (offset) => pull(offset),
1146
1149
  (offset) => pull(offset, true),
1147
1150
  ];
1148
- usePointerSwipe(...swipeParams, closeOnPullUp, closeOnPullDown, ...pullParams);
1151
+ usePointerSwipe(controller, ...swipeParams, closeOnPullUp, closeOnPullDown, ...pullParams);
1149
1152
  useWheelSwipe(swipeState, ...swipeParams);
1150
1153
  const focusOnMount = useEventCallback(() => {
1151
1154
  if (controller.focus &&
@@ -1205,7 +1208,7 @@ function Controller({ children, ...props }) {
1205
1208
  : null),
1206
1209
  ...(controller.touchAction !== "none" ? { [cssVar("controller_touch_action")]: controller.touchAction } : null),
1207
1210
  ...styles.container,
1208
- }, ...(controller.aria ? { role: "presentation", "aria-live": "polite" } : null), tabIndex: -1, ...registerSensors }, containerRect && (React.createElement(ControllerContext.Provider, { value: context },
1211
+ }, ...(controller.aria ? { role: "region", "aria-live": "polite", "aria-roledescription": "carousel" } : null), tabIndex: -1, ...registerSensors }, containerRect && (React.createElement(ControllerContext.Provider, { value: context },
1209
1212
  children, (_a = render.controls) === null || _a === void 0 ? void 0 :
1210
1213
  _a.call(render)))));
1211
1214
  }
@@ -1253,7 +1256,7 @@ function CarouselSlide({ slide, offset }) {
1253
1256
  close();
1254
1257
  }
1255
1258
  };
1256
- return (React.createElement("div", { ref: containerRef, className: clsx(cssClass(cssSlidePrefix()), !offscreen && cssClass(cssSlidePrefix("current")), cssClass(CLASS_FLEX_CENTER)), ...makeInertWhen(offscreen), onClick: handleBackdropClick, style: style }, renderSlide()));
1259
+ return (React.createElement("div", { ref: containerRef, className: clsx(cssClass(cssSlidePrefix()), !offscreen && cssClass(cssSlidePrefix("current")), cssClass(CLASS_FLEX_CENTER)), ...makeInertWhen(offscreen), onClick: handleBackdropClick, style: style, role: "region", "aria-roledescription": "slide" }, renderSlide()));
1257
1260
  }
1258
1261
  function Placeholder() {
1259
1262
  const style = useLightboxProps().styles.slide;
@@ -1469,7 +1472,7 @@ function Portal({ children, animation, styles, className, on, portal, close }) {
1469
1472
  }
1470
1473
  }, [handleEnter, handleCleanup]);
1471
1474
  return mounted
1472
- ? createPortal(React.createElement(LightboxRoot, { ref: handleRef, className: clsx(className, cssClass(cssPrefix$1()), cssClass(CLASS_NO_SCROLL_PADDING), visible && cssClass(cssPrefix$1("open"))), role: "presentation", "aria-live": "polite", style: {
1475
+ ? createPortal(React.createElement(LightboxRoot, { ref: handleRef, className: clsx(className, cssClass(cssPrefix$1()), cssClass(CLASS_NO_SCROLL_PADDING), visible && cssClass(cssPrefix$1("open"))), "aria-modal": true, role: "dialog", "aria-live": "polite", "aria-roledescription": "lightbox", style: {
1473
1476
  ...(animation.fade !== LightboxDefaultProps.animation.fade
1474
1477
  ? { [cssVar("fade_animation_duration")]: `${animationDuration}ms` }
1475
1478
  : null),
@@ -109,8 +109,8 @@ function ThumbnailsTrack({ visible, containerRef }) {
109
109
  useKeyboardNavigation(subscribeSensors);
110
110
  const thumbnails = useThumbnailsProps();
111
111
  const { position, width, height, border, borderStyle, borderColor, borderRadius, padding, gap, vignette } = thumbnails;
112
+ const offset = ((animation === null || animation === void 0 ? void 0 : animation.duration) !== undefined && (animation === null || animation === void 0 ? void 0 : animation.increment)) || 0;
112
113
  const animationDuration = (animation === null || animation === void 0 ? void 0 : animation.duration) || 0;
113
- const offset = (animationDuration > 0 && (animation === null || animation === void 0 ? void 0 : animation.increment)) || 0;
114
114
  const { prepareAnimation } = useAnimation(track, (snapshot) => ({
115
115
  keyframes: isHorizontal(position)
116
116
  ? [
@@ -14,9 +14,9 @@ declare module "yet-another-react-lightbox" {
14
14
  maxZoomPixelRatio?: number;
15
15
  /** zoom-in multiplier */
16
16
  zoomInMultiplier?: number;
17
- /** double-tap maximum time delay */
17
+ /** @deprecated - double-tap maximum time delay */
18
18
  doubleTapDelay?: number;
19
- /** double-click maximum time delay */
19
+ /** @deprecated - double-click maximum time delay */
20
20
  doubleClickDelay?: number;
21
21
  /** maximum number of zoom-in stops via double-click or double-tap */
22
22
  doubleClickMaxStops?: number;
package/dist/types.d.ts CHANGED
@@ -240,6 +240,8 @@ interface ControllerSettings {
240
240
  preventDefaultWheelX: boolean;
241
241
  /** if `true`, prevent default for vertical wheel scroll events (for internal use only) */
242
242
  preventDefaultWheelY: boolean;
243
+ /** if `true`, disable slide change on pointer swipe / drag */
244
+ disableSwipeNavigation: boolean;
243
245
  }
244
246
  /** Lightbox controller ref */
245
247
  interface ControllerRef {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.21.9",
3
+ "version": "3.23.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",