yet-another-react-lightbox 1.6.0 → 1.7.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.
@@ -4,10 +4,12 @@ import { useLatest } from "../hooks/index.js";
4
4
  import { useEvents } from "../contexts/index.js";
5
5
  import { ErrorIcon, LoadingIcon } from "./Icons.js";
6
6
  import { activeSlideStatus, SLIDE_STATUS_COMPLETE, SLIDE_STATUS_ERROR, SLIDE_STATUS_LOADING } from "../consts.js";
7
+ import { useController } from "../modules/Controller.js";
7
8
  export const ImageSlide = ({ slide: image, offset, render, rect }) => {
8
9
  var _a;
9
10
  const [status, setStatus] = React.useState(SLIDE_STATUS_LOADING);
10
11
  const latestStatus = useLatest(status);
12
+ const { latestProps } = useController();
11
13
  const { publish } = useEvents();
12
14
  const imageRef = React.useRef(null);
13
15
  React.useEffect(() => {
@@ -41,7 +43,9 @@ export const ImageSlide = ({ slide: image, offset, render, rect }) => {
41
43
  setStatus(SLIDE_STATUS_ERROR);
42
44
  }, []);
43
45
  return (React.createElement(React.Fragment, null,
44
- React.createElement("img", { ref: setImageRef, onLoad: onLoad, onError: onError, className: clsx(cssClass("slide_image"), status !== SLIDE_STATUS_COMPLETE && cssClass("slide_image_loading")), draggable: false, alt: image.alt, ...(image.srcSet
46
+ React.createElement("img", { ref: setImageRef, onLoad: onLoad, onError: onError, className: clsx(cssClass("slide_image"), (image.imageFit === "cover" ||
47
+ (image.imageFit !== "contain" && latestProps.current.carousel.imageFit === "cover")) &&
48
+ cssClass("slide_image_cover"), status !== SLIDE_STATUS_COMPLETE && cssClass("slide_image_loading")), draggable: false, alt: image.alt, ...(image.srcSet
45
49
  ? {
46
50
  ...(rect && hasWindow()
47
51
  ? {
package/dist/styles.css CHANGED
@@ -14,7 +14,7 @@
14
14
  -moz-user-select: none;
15
15
  -ms-user-select: none;
16
16
  user-select: none;
17
- touch-action: none;
17
+ touch-action: pan-y;
18
18
  }
19
19
  .yarl__container {
20
20
  width: 100%;
@@ -65,6 +65,12 @@
65
65
  user-select: none;
66
66
  -webkit-user-select: none;
67
67
  -webkit-touch-callout: none;
68
+ -webkit-transform: translate3d(0, 0, 0);
69
+ transform: translate3d(0, 0, 0);
70
+ }
71
+ .yarl__slide_image_cover {
72
+ -o-object-fit: cover;
73
+ object-fit: cover;
68
74
  }
69
75
  .yarl__slide_image_loading {
70
76
  opacity: 0;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ContainerRect } from "./core/hooks/useContainerRect.js";
3
+ /** Image fit setting */
4
+ export declare type ImageFit = "contain" | "cover";
3
5
  /** Image slide properties */
4
6
  export interface SlideImage {
5
7
  /** image URL */
@@ -8,6 +10,8 @@ export interface SlideImage {
8
10
  alt?: string;
9
11
  /** image aspect ratio */
10
12
  aspectRatio?: number;
13
+ /** `object-fit` setting */
14
+ imageFit?: ImageFit;
11
15
  /** alternative images to be passed to the 'srcSet' */
12
16
  srcSet?: {
13
17
  /** image URL */
@@ -33,6 +37,8 @@ export interface CarouselSettings {
33
37
  padding: string | number;
34
38
  /** spacing between slides (e.g., "100px", "50%" or 0) */
35
39
  spacing: string | number;
40
+ /** `object-fit` setting for image slides */
41
+ imageFit: ImageFit;
36
42
  }
37
43
  /** Animation settings */
38
44
  export interface AnimationSettings {
@@ -43,7 +49,7 @@ export interface AnimationSettings {
43
49
  }
44
50
  /** Controller settings */
45
51
  export interface ControllerSettings {
46
- /** if true, the lightbox captures focus when it opens v */
52
+ /** if true, the lightbox captures focus when it opens */
47
53
  focus: boolean;
48
54
  }
49
55
  /** Custom render functions. */
package/dist/types.js CHANGED
@@ -16,6 +16,7 @@ export const LightboxDefaultProps = {
16
16
  preload: 2,
17
17
  padding: "16px",
18
18
  spacing: "30%",
19
+ imageFit: "contain",
19
20
  },
20
21
  controller: {
21
22
  focus: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",
@@ -100,7 +100,7 @@
100
100
  "eslint-plugin-jsx-a11y": "^6.5.1",
101
101
  "eslint-plugin-prettier": "^4.0.0",
102
102
  "eslint-plugin-react": "^7.30.0",
103
- "eslint-plugin-react-hooks": "^4.5.0",
103
+ "eslint-plugin-react-hooks": "^4.6.0",
104
104
  "husky": "^8.0.1",
105
105
  "jest": "^28.1.1",
106
106
  "jest-environment-jsdom": "^28.1.1",
@@ -109,8 +109,8 @@
109
109
  "postcss": "^8.4.14",
110
110
  "postcss-cli": "^9.1.0",
111
111
  "prettier": "^2.7.0",
112
- "react": "^18.1.0",
113
- "react-dom": "^18.1.0",
112
+ "react": "^18.2.0",
113
+ "react-dom": "^18.2.0",
114
114
  "rimraf": "^3.0.2",
115
115
  "sass": "^1.52.3",
116
116
  "ts-jest": "^28.0.5",