yet-another-react-lightbox 2.2.7 → 2.3.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 +1 -1
- package/dist/core/components/ImageSlide.d.ts +1 -2
- package/dist/core/hooks/useContainerRect.d.ts +1 -4
- package/dist/core/modules/Controller.d.ts +2 -2
- package/dist/plugins/thumbnails/Thumbnail.d.ts +1 -2
- package/dist/plugins/thumbnails/ThumbnailsTrack.d.ts +1 -2
- package/dist/plugins/thumbnails/index.d.ts +0 -1
- package/dist/plugins/zoom/ZoomContainer.d.ts +1 -2
- package/dist/plugins/zoom/ZoomContainer.js +7 -0
- package/dist/plugins/zoom/index.d.ts +3 -0
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ export default App;
|
|
|
78
78
|
|
|
79
79
|
Unlike many other lightbox libraries, Yet Another React Lightbox doesn't have a concept of "thumbnail" or "original"
|
|
80
80
|
(or "full size") images. We use responsive images instead and recommend you provide multiple files of different
|
|
81
|
-
resolutions for each image. Yet Another React Lightbox automatically populates `
|
|
81
|
+
resolutions for each image. Yet Another React Lightbox automatically populates `srcset` / `sizes` attributes and lets
|
|
82
82
|
the browser decide which image is more appropriate for its viewport size.
|
|
83
83
|
|
|
84
84
|
```jsx
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ImageFit, Render, SlideImage } from "../../types.js";
|
|
3
|
-
import { ContainerRect } from "../hooks/index.js";
|
|
2
|
+
import { ContainerRect, ImageFit, Render, SlideImage } from "../../types.js";
|
|
4
3
|
export type ImageSlideProps = {
|
|
5
4
|
slide: SlideImage;
|
|
6
5
|
offset?: number;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
};
|
|
2
|
+
import { ContainerRect } from "../../types.js";
|
|
6
3
|
export declare const useContainerRect: <T extends HTMLElement = HTMLElement>() => {
|
|
7
4
|
setContainerRef: (node: T | null) => void;
|
|
8
5
|
containerRef: React.MutableRefObject<T | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Component, ComponentProps } from "../../types.js";
|
|
3
|
-
import {
|
|
2
|
+
import { Component, ComponentProps, ContainerRect } from "../../types.js";
|
|
3
|
+
import { SubscribeSensors } from "../hooks/index.js";
|
|
4
4
|
export type ControllerContextType = {
|
|
5
5
|
getLightboxProps: () => ComponentProps;
|
|
6
6
|
subscribeSensors: SubscribeSensors<HTMLDivElement>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ImageFit, LightboxProps, Slide } from "../../types.js";
|
|
3
|
-
import { ContainerRect } from "../../core/index.js";
|
|
2
|
+
import { ContainerRect, ImageFit, LightboxProps, Slide } from "../../types.js";
|
|
4
3
|
type FadeSettings = {
|
|
5
4
|
duration: number;
|
|
6
5
|
delay: number;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ContainerRect } from "../../
|
|
3
|
-
import { DeepNonNullable, LightboxProps } from "../../types.js";
|
|
2
|
+
import { ContainerRect, DeepNonNullable, LightboxProps } from "../../types.js";
|
|
4
3
|
type ThumbnailsInternal = DeepNonNullable<LightboxProps["thumbnails"]>;
|
|
5
4
|
type ThumbnailsTrackProps = Pick<LightboxProps, "slides" | "carousel" | "animation" | "render" | "styles"> & {
|
|
6
5
|
container: React.RefObject<HTMLDivElement>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ContainerRect } from "../../
|
|
3
|
-
import { LightboxProps, Slide } from "../../types.js";
|
|
2
|
+
import { ContainerRect, LightboxProps, Slide } from "../../types.js";
|
|
4
3
|
/** Zoom container */
|
|
5
4
|
export declare const ZoomContainer: React.FC<Pick<LightboxProps, "render" | "carousel" | "zoom" | "animation" | "on"> & {
|
|
6
5
|
slide: Slide;
|
|
@@ -140,6 +140,13 @@ export const ZoomContainer = ({ slide, offset, rect, render, carousel, animation
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}, [offset, zoom, maxZoom, isMinZoom, isMaxZoom, setIsMinZoom, setIsMaxZoom]);
|
|
143
|
+
const onZoomCallback = useEventCallback(() => {
|
|
144
|
+
var _a;
|
|
145
|
+
if (offset === 0) {
|
|
146
|
+
(_a = on.zoom) === null || _a === void 0 ? void 0 : _a.call(on, zoom);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
useLayoutEffect(onZoomCallback, [zoom, onZoomCallback]);
|
|
143
150
|
const translateCoordinates = React.useCallback((event) => {
|
|
144
151
|
if (controllerRef.current) {
|
|
145
152
|
const { pageX, pageY } = event;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ContainerRect } from "./core/hooks/useContainerRect.js";
|
|
3
2
|
/** Image fit setting */
|
|
4
3
|
export type ImageFit = "contain" | "cover";
|
|
5
4
|
/** Image source */
|
|
@@ -38,6 +37,11 @@ export interface SlideTypes {
|
|
|
38
37
|
}
|
|
39
38
|
/** Slide */
|
|
40
39
|
export type Slide = SlideTypes[keyof SlideTypes];
|
|
40
|
+
/** Container rect */
|
|
41
|
+
export type ContainerRect = {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
41
45
|
/** Supported customization slots */
|
|
42
46
|
export interface SlotType {
|
|
43
47
|
/** lightbox root customization slot */
|