yet-another-react-lightbox-lite 1.5.0 → 1.6.1

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;
@@ -272,38 +272,39 @@ function useSensors() {
272
272
  };
273
273
  return useMemo(() => {
274
274
  const onKeyDown = (event) => {
275
- const meta = event.getModifierState("Meta");
275
+ const { key, metaKey, ctrlKey } = event;
276
+ const meta = metaKey || ctrlKey;
276
277
  const preventDefault = () => event.preventDefault();
277
278
  const handleChangeZoom = (newZoom) => {
278
279
  preventDefault();
279
280
  changeZoom(newZoom);
280
281
  };
281
- if (event.key === "+" || (meta && event.key === "="))
282
+ if (key === "+" || (meta && key === "="))
282
283
  handleChangeZoom(zoom * KEYBOARD_ZOOM_FACTOR);
283
- if (event.key === "-" || (meta && event.key === "_"))
284
+ if (key === "-" || (meta && key === "_"))
284
285
  handleChangeZoom(zoom / KEYBOARD_ZOOM_FACTOR);
285
- if (meta && event.key === "0")
286
+ if (meta && key === "0")
286
287
  handleChangeZoom(1);
287
- if (event.key === "Escape")
288
+ if (key === "Escape")
288
289
  close();
289
290
  if (zoom > 1) {
290
291
  const move = (deltaX, deltaY) => {
291
292
  preventDefault();
292
293
  changeOffsets(deltaX, deltaY);
293
294
  };
294
- if (event.key === "ArrowUp")
295
+ if (key === "ArrowUp")
295
296
  move(0, KEYBOARD_MOVE_DISTANCE);
296
- if (event.key === "ArrowDown")
297
+ if (key === "ArrowDown")
297
298
  move(0, -KEYBOARD_MOVE_DISTANCE);
298
- if (event.key === "ArrowLeft")
299
+ if (key === "ArrowLeft")
299
300
  move(KEYBOARD_MOVE_DISTANCE, 0);
300
- if (event.key === "ArrowRight")
301
+ if (key === "ArrowRight")
301
302
  move(-KEYBOARD_MOVE_DISTANCE, 0);
302
303
  return;
303
304
  }
304
- if (event.key === "ArrowLeft")
305
+ if (key === "ArrowLeft")
305
306
  prev();
306
- if (event.key === "ArrowRight")
307
+ if (key === "ArrowRight")
307
308
  next();
308
309
  };
309
310
  const removePointer = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox-lite",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Lightweight React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",