yet-another-react-lightbox-lite 1.4.1 → 1.6.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/README.md CHANGED
@@ -418,6 +418,24 @@ Type: `string`
418
418
  CSS class of the lightbox root element. You can use this class name to provide
419
419
  module-scoped style overrides.
420
420
 
421
+ ### zoom
422
+
423
+ Type: `object`
424
+
425
+ Zoom settings.
426
+
427
+ - `disabled` - disable zoom on image slides
428
+ - `supports` - zoom-enabled custom slide types
429
+
430
+ Usage example:
431
+
432
+ ```tsx
433
+ <Lightbox
434
+ zoom={{ supports: ["custom-slide-type"] }}
435
+ // ...
436
+ />
437
+ ```
438
+
421
439
  ## Custom Slide Attributes
422
440
 
423
441
  You can add custom slide attributes with the following module augmentation.
package/dist/index.d.ts CHANGED
@@ -127,6 +127,8 @@ interface ControllerSettings {
127
127
  }
128
128
  /** Zoom settings */
129
129
  interface ZoomSettings {
130
+ /** disable zoom on image slides */
131
+ disabled?: boolean;
130
132
  /** zoom-enabled custom slide types */
131
133
  supports?: SlideTypeKey[];
132
134
  }
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ function Zoom({ children }) {
95
95
  const [rect, setRect] = useState();
96
96
  const observer = useRef();
97
97
  const carouselRef = useRef(null);
98
- const { index, slides, zoom: { supports } = {} } = useLightboxContext();
98
+ const { index, slides, zoom: { supports, disabled } = {} } = useLightboxContext();
99
99
  const [prevIndex, setPrevIndex] = useState(index);
100
100
  if (index !== prevIndex) {
101
101
  setZoom(1);
@@ -104,7 +104,7 @@ function Zoom({ children }) {
104
104
  setPrevIndex(index);
105
105
  }
106
106
  const slide = slides[index];
107
- const maxZoom = isImageSlide(slide) || (supports || []).includes(slide.type) ? 8 : 1;
107
+ const maxZoom = (isImageSlide(slide) && !disabled) || (supports || []).includes(slide.type) ? 8 : 1;
108
108
  useLayoutEffect(() => {
109
109
  const carouselHalfWidth = (rect?.width || 0) / 2;
110
110
  const carouselHalfHeight = (rect?.height || 0) / 2;
@@ -261,7 +261,7 @@ function useSensors() {
261
261
  const wheelCooldownMomentum = useRef(null);
262
262
  const activePointers = useRef([]);
263
263
  const pinchZoomDistance = useRef();
264
- const { zoom, changeZoom, changeOffsets } = useZoom();
264
+ const { zoom, maxZoom, changeZoom, changeOffsets } = useZoom();
265
265
  const { carouselRef } = useZoomInternal();
266
266
  const { prev, next, close } = useController();
267
267
  const { closeOnPullUp, closeOnPullDown, closeOnBackdropClick } = {
@@ -423,6 +423,9 @@ function useSensors() {
423
423
  wheelCooldownMomentum.current = event.deltaX;
424
424
  }
425
425
  };
426
+ const onDoubleClick = (event) => {
427
+ changeZoom(zoom < maxZoom ? scaleZoom(zoom, 2, 1) : 1, event);
428
+ };
426
429
  return {
427
430
  onKeyDown,
428
431
  onPointerDown,
@@ -430,6 +433,7 @@ function useSensors() {
430
433
  onPointerUp,
431
434
  onPointerLeave: onPointerUp,
432
435
  onPointerCancel: onPointerUp,
436
+ onDoubleClick,
433
437
  onWheel,
434
438
  };
435
439
  }, [
@@ -437,6 +441,7 @@ function useSensors() {
437
441
  next,
438
442
  close,
439
443
  zoom,
444
+ maxZoom,
440
445
  changeZoom,
441
446
  changeOffsets,
442
447
  carouselRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox-lite",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "description": "Lightweight React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",