react-lazy-img-observer 1.0.1 → 1.1.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/LICENCE.md CHANGED
@@ -1,21 +1,21 @@
1
- ISC License (ISC)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2023 Percy Saul Rondan Chuzon
4
4
 
5
- Se concede permiso, de forma gratuita, a cualquier persona que obtenga una copia
6
- de este software y de los archivos de documentación asociados (el "Software"),
7
- para tratar el Software sin restricción, incluidos, entre otros, los derechos de
8
- uso, copia, modificación, fusión, publicación, distribución, sublicencia y/o
9
- venta de copias del Software y para permitir a las personas a las que se les
10
- proporcione el Software a hacerlo, sujeto a las siguientes condiciones:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the Software), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
11
 
12
- El aviso de copyright anterior y este aviso de permisos se incluirán en todas
13
- las copias o partes sustanciales del Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
14
 
15
- EL SOFTWARE SE PROPORCIONA "TAL CUAL", SIN GARANTÍA DE NINGÚN TIPO, EXPRESA O
16
- IMPLÍCITA, INCLUYENDO PERO NO LIMITADO A LAS GARANTÍAS DE COMERCIABILIDAD,
17
- IDONEIDAD PARA UN PROPÓSITO PARTICULAR Y NO INFRACCIÓN. EN NINGÚN CASO LOS
18
- AUTORES O TITULARES DE DERECHOS DE AUTOR SERÁN RESPONSABLES DE NINGUNA
19
- RECLAMACIÓN, DAÑO U OTRA RESPONSABILIDAD, YA SEA EN UNA ACCIÓN DE CONTRATO,
20
- AGRAVIO O DE OTRO MODO, DERIVADA DE, FUERA DE O EN CONEXIÓN CON EL SOFTWARE
21
- O EL USO U OTROS TRATOS EN EL SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,125 +1,112 @@
1
- # ImageLazy Component
2
-
3
- The `ImageLazy` component is a React component designed for lazy loading images. It leverages the Intersection Observer API to load images only when they are within the viewport, optimizing the loading performance of your web application.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install react-lazy-img-observer
9
- ```
10
-
11
- # Usage
12
-
13
- ```javascript
14
- import ImageLazy from "react-lazy-img-observer";
15
-
16
- const Example = () => {
17
- return (
18
- <ImageLazy
19
- src="path/to/your/image.jpg"
20
- alt="Description of the image"
21
- width={600}
22
- height={400}
23
- className="your-class-name"
24
- id="unique-image-id"
25
- title="Image Title"
26
- extraData={{ "data-custom-attribute": "value" }}
27
- />
28
- );
29
- };
30
- ```
31
-
32
- ## Props
33
-
34
- The ImageLazy component accepts the following props:
35
-
36
- | Prop | Type | Default | Description |
37
- | ----------- | ------------------------------------------- | ------- | --------------------------------------------------- |
38
- | `src` | `string` | - | The source URL of the image. |
39
- | `alt` | `string` | - | The alt text for the image. |
40
- | `width` | `number` | - | The width of the image. |
41
- | `height` | `number` | - | The height of the image. |
42
- | `id` | `number \| string` | - | The ID of the image element. |
43
- | `className` | `string` | - | Additional class names for the image element. |
44
- | `title` | `string` | - | The title attribute for the image element. |
45
- | `extraData` | `React.ImgHTMLAttributes<HTMLImageElement>` | - | Additional attributes to pass to the image element. |
46
-
47
-
48
- ## Example
49
-
50
- ```javascript
51
- import React from 'react';
52
- import ImageLazy from 'your-library-name';
53
-
54
- const App = () => {
55
- return (
56
- <div>
57
- <h1>Lazy Loaded Images</h1>
58
- <ImageLazy
59
- src="https://example.com/image1.jpg"
60
- alt="Image 1"
61
- width={600}
62
- height={400}
63
- className="image-class"
64
- id="image1"
65
- title="First Image"
66
- />
67
- <ImageLazy
68
- src="https://example.com/image2.jpg"
69
- alt="Image 2"
70
- width={600}
71
- height={400}
72
- className="image-class"
73
- id="image2"
74
- title="Second Image"
75
- />
76
- </div>
77
- );
78
- };
79
-
80
- export default App;
81
-
82
- ```
83
-
84
- ## How it works
85
-
86
- The `ImageLazy` component uses the IntersectionObserver API to detect when the image enters the viewport. When the image is about to enter the viewport (50% visibility by default), the component sets the `src` attribute of the image element to load the actual image.
87
-
88
- ## Intersection Observer Options
89
-
90
- - **`root`**: The element that is used as the viewport for checking visibility of the target. Defaults to `null` (the browser viewport).
91
- - **`rootMargin`**: Margin around the root. Can be used to grow or shrink the area used for intersection. Defaults to `"0px"`.
92
- - **`threshold`**: A single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. Defaults to `0.5`.
93
-
94
-
95
- ## Styling
96
-
97
- The `ImageLazy` component applies a blur filter to the image until it is fully loaded. You can customize the transition effect and blur amount through the `style` prop or CSS class.
98
-
99
- ```css
100
- .image-class {
101
- filter: blur(10px);
102
- transition: filter 0.9s;
103
- }
104
-
105
- .image-class[data-src] {
106
- filter: none;
107
- }
108
-
109
- ```
110
-
111
- ## License
112
-
113
- MIT
114
-
115
- ## Contributing
116
-
117
- Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
118
-
119
- ## Author
120
-
121
- Percy Chuzon
122
-
123
- ## Acknowledgments
124
-
125
- Thanks to the React and Intersection Observer API documentation for guidance.
1
+ # 📷 ImageLazy
2
+
3
+ **ImageLazy** is a lightweight React component for lazy loading images using the Intersection Observer API. It delays the loading of off-screen images until they appear in the viewport, helping optimize performance and reduce initial load times.
4
+
5
+ ![npm](https://img.shields.io/npm/v/react-lazy-img-observer.svg)
6
+ ![license](https://img.shields.io/npm/l/react-lazy-img-observer.svg)
7
+
8
+ ---
9
+
10
+ ## 📦 Installation
11
+
12
+ ```bash
13
+ npm install react-lazy-img-observer
14
+ ```
15
+
16
+ ---
17
+
18
+ ## 🚀 Usage
19
+
20
+ ### Basic example (JSX or TSX)
21
+
22
+ ```tsx
23
+ import ImageLazy from "react-lazy-img-observer";
24
+
25
+ const Example = () => (
26
+ <ImageLazy
27
+ src="https://example.com/image.jpg"
28
+ alt="Description of the image"
29
+ width={600}
30
+ height={400}
31
+ className="custom-class"
32
+ id="image-1"
33
+ title="Image title"
34
+ extraData={{ "data-custom": "value" }}
35
+ />
36
+ );
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 🧩 Props
42
+
43
+ | Prop | Type | Required | Description |
44
+ |-------------|---------------------------------------------|----------|-------------------------------------------------------|
45
+ | `src` | `string` | | The source URL of the image. |
46
+ | `alt` | `string` | ✅ | The alt text for accessibility. |
47
+ | `width` | `number` | ❌ | The width of the image. |
48
+ | `height` | `number` | ❌ | The height of the image. |
49
+ | `id` | `string \| number` | ❌ | Optional ID for the image element. |
50
+ | `className` | `string` | ❌ | CSS class for custom styling. |
51
+ | `title` | `string` | ❌ | Tooltip text shown on hover. |
52
+ | `extraData` | `React.ImgHTMLAttributes<HTMLImageElement>` | ❌ | Any extra HTML attributes (e.g., `data-*`). |
53
+
54
+ ---
55
+
56
+ ## 📚 How It Works
57
+
58
+ The component uses the [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) API to detect when the image enters the viewport. Once at least **50%** of the image is visible, the real `src` is assigned to the image, triggering the browser to load it.
59
+
60
+ ---
61
+
62
+ ## ⚙️ Intersection Observer Configuration
63
+
64
+ - `root`: `null` (default viewport)
65
+ - `rootMargin`: `"0px"`
66
+ - `threshold`: `0.5` (50% visibility required)
67
+
68
+ ---
69
+
70
+ ## 🎨 Styling
71
+
72
+ The image starts blurred and transitions smoothly once it’s loaded. You can override or enhance this with your own styles:
73
+
74
+ ```css
75
+ .custom-class {
76
+ filter: blur(20px);
77
+ transition: filter 0.9s ease;
78
+ }
79
+
80
+ .custom-class.loaded {
81
+ filter: none;
82
+ }
83
+ ```
84
+
85
+ You may also override the `style` prop directly if preferred.
86
+
87
+ ---
88
+
89
+ ## 📄 License
90
+
91
+ [ISC License](./LICENSE)
92
+
93
+ ---
94
+
95
+ ## 🤝 Contributing
96
+
97
+ Contributions are welcome!
98
+ Feel free to [open an issue](https://github.com/perch33/react-lazy-img-observer/issues) or submit a pull request.
99
+
100
+ ---
101
+
102
+ ## 👤 Author
103
+
104
+ **Percy Chuzon**
105
+ 📧 contacto@percychuzon.com
106
+ 🌐 [https://percychuzon.com](https://percychuzon.com)
107
+
108
+ ---
109
+
110
+ ## 🙏 Acknowledgments
111
+
112
+ Thanks to the React community and the MDN docs for inspiration and guidance.
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageLazy = void 0;
3
4
  const jsx_runtime_1 = require("react/jsx-runtime");
4
5
  const react_1 = require("react");
5
6
  const ImageLazy = ({ src, alt, width, height, className, id, extraData, title, }) => {
6
7
  const imageRef = (0, react_1.useRef)(null);
7
8
  const [isIntersecting, setIsIntersecting] = (0, react_1.useState)(false);
8
9
  (0, react_1.useEffect)(() => {
10
+ if (typeof IntersectionObserver === "undefined" ||
11
+ !imageRef.current) {
12
+ return;
13
+ }
9
14
  const observer = new IntersectionObserver((entries) => {
10
15
  entries.forEach((entry) => {
11
16
  if (entry.isIntersecting) {
@@ -16,19 +21,20 @@ const ImageLazy = ({ src, alt, width, height, className, id, extraData, title, }
16
21
  observer.unobserve(entry.target);
17
22
  }
18
23
  });
19
- }, { root: null, rootMargin: "0px", threshold: 0.5 });
20
- if (imageRef.current) {
21
- observer.observe(imageRef.current);
22
- }
24
+ }, {
25
+ root: null,
26
+ rootMargin: "0px",
27
+ threshold: 0.5,
28
+ });
29
+ observer.observe(imageRef.current);
23
30
  return () => {
24
- if (imageRef.current) {
25
- observer.unobserve(imageRef.current);
26
- }
31
+ observer.disconnect();
27
32
  };
28
33
  }, [src]);
29
- return ((0, jsx_runtime_1.jsx)("img", { title: title, className: className, loading: "lazy", ref: imageRef, "data-src": src, alt: alt, width: width, height: height, style: {
34
+ return ((0, jsx_runtime_1.jsx)("img", { ref: imageRef, "data-src": src, alt: alt, title: title, className: className, width: width, height: height, loading: "lazy", id: id?.toString(), style: {
30
35
  filter: isIntersecting ? "none" : "blur(20px)",
31
36
  transition: "filter 0.9s",
32
- }, id: id?.toString(), ...extraData }));
37
+ }, ...extraData }));
33
38
  };
39
+ exports.ImageLazy = ImageLazy;
34
40
  exports.default = ImageLazy;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ImageLazy=({src:e,alt:t,width:r,height:s,className:a,id:n,extraData:c,title:i})=>{const u=(0,react_1.useRef)(null),[o,l]=(0,react_1.useState)(!1);return(0,react_1.useEffect)((()=>{const e=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(l(!0),u.current&&(u.current.src=u.current.dataset.src||""),e.unobserve(t.target))}))}),{root:null,rootMargin:"0px",threshold:.5});return u.current&&e.observe(u.current),()=>{u.current&&e.unobserve(u.current)}}),[e]),(0,jsx_runtime_1.jsx)("img",{title:i,className:a,loading:"lazy",ref:u,"data-src":e,alt:t,width:r,height:s,style:{filter:o?"none":"blur(20px)",transition:"filter 0.9s"},id:n?.toString(),...c})};exports.default=ImageLazy;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImageLazy=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ImageLazy=({src:e,alt:t,width:r,height:s,className:a,id:n,extraData:i,title:c})=>{const o=(0,react_1.useRef)(null),[u,l]=(0,react_1.useState)(!1);return(0,react_1.useEffect)((()=>{if("undefined"==typeof IntersectionObserver||!o.current)return;const e=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(l(!0),o.current&&(o.current.src=o.current.dataset.src||""),e.unobserve(t.target))}))}),{root:null,rootMargin:"0px",threshold:.5});return e.observe(o.current),()=>{e.disconnect()}}),[e]),(0,jsx_runtime_1.jsx)("img",{ref:o,"data-src":e,alt:t,title:c,className:a,width:r,height:s,loading:"lazy",id:n?.toString(),style:{filter:u?"none":"blur(20px)",transition:"filter 0.9s"},...i})};exports.ImageLazy=ImageLazy,exports.default=ImageLazy;
@@ -4,6 +4,10 @@ const ImageLazy = ({ src, alt, width, height, className, id, extraData, title, }
4
4
  const imageRef = useRef(null);
5
5
  const [isIntersecting, setIsIntersecting] = useState(false);
6
6
  useEffect(() => {
7
+ if (typeof IntersectionObserver === "undefined" ||
8
+ !imageRef.current) {
9
+ return;
10
+ }
7
11
  const observer = new IntersectionObserver((entries) => {
8
12
  entries.forEach((entry) => {
9
13
  if (entry.isIntersecting) {
@@ -14,19 +18,20 @@ const ImageLazy = ({ src, alt, width, height, className, id, extraData, title, }
14
18
  observer.unobserve(entry.target);
15
19
  }
16
20
  });
17
- }, { root: null, rootMargin: "0px", threshold: 0.5 });
18
- if (imageRef.current) {
19
- observer.observe(imageRef.current);
20
- }
21
+ }, {
22
+ root: null,
23
+ rootMargin: "0px",
24
+ threshold: 0.5,
25
+ });
26
+ observer.observe(imageRef.current);
21
27
  return () => {
22
- if (imageRef.current) {
23
- observer.unobserve(imageRef.current);
24
- }
28
+ observer.disconnect();
25
29
  };
26
30
  }, [src]);
27
- return (_jsx("img", { title: title, className: className, loading: "lazy", ref: imageRef, "data-src": src, alt: alt, width: width, height: height, style: {
31
+ return (_jsx("img", { ref: imageRef, "data-src": src, alt: alt, title: title, className: className, width: width, height: height, loading: "lazy", id: id?.toString(), style: {
28
32
  filter: isIntersecting ? "none" : "blur(20px)",
29
33
  transition: "filter 0.9s",
30
- }, id: id?.toString(), ...extraData }));
34
+ }, ...extraData }));
31
35
  };
32
36
  export default ImageLazy;
37
+ export { ImageLazy };
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useRef,useState}from"react";const ImageLazy=({src:e,alt:t,width:r,height:s,className:a,id:n,extraData:c,title:i})=>{const o=useRef(null),[u,l]=useState(!1);return useEffect((()=>{const e=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(l(!0),o.current&&(o.current.src=o.current.dataset.src||""),e.unobserve(t.target))}))}),{root:null,rootMargin:"0px",threshold:.5});return o.current&&e.observe(o.current),()=>{o.current&&e.unobserve(o.current)}}),[e]),_jsx("img",{title:i,className:a,loading:"lazy",ref:o,"data-src":e,alt:t,width:r,height:s,style:{filter:u?"none":"blur(20px)",transition:"filter 0.9s"},id:n?.toString(),...c})};export default ImageLazy;
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useRef,useState}from"react";const ImageLazy=({src:e,alt:t,width:r,height:s,className:n,id:a,extraData:i,title:o})=>{const c=useRef(null),[u,l]=useState(!1);return useEffect((()=>{if("undefined"==typeof IntersectionObserver||!c.current)return;const e=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(l(!0),c.current&&(c.current.src=c.current.dataset.src||""),e.unobserve(t.target))}))}),{root:null,rootMargin:"0px",threshold:.5});return e.observe(c.current),()=>{e.disconnect()}}),[e]),_jsx("img",{ref:c,"data-src":e,alt:t,title:o,className:n,width:r,height:s,loading:"lazy",id:a?.toString(),style:{filter:u?"none":"blur(20px)",transition:"filter 0.9s"},...i})};export default ImageLazy;export{ImageLazy};
@@ -10,3 +10,4 @@ type ImagesLazy = {
10
10
  };
11
11
  declare const ImageLazy: ({ src, alt, width, height, className, id, extraData, title, }: ImagesLazy) => import("react/jsx-runtime").JSX.Element;
12
12
  export default ImageLazy;
13
+ export { ImageLazy };
package/package.json CHANGED
@@ -1,37 +1,67 @@
1
1
  {
2
2
  "name": "react-lazy-img-observer",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "A React component for lazy loading images with Intersection Observer",
5
5
  "main": "dist/cjs/ImageLazy.min.js",
6
6
  "module": "dist/esm/ImageLazy.min.js",
7
7
  "types": "dist/types/ImageLazy.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/esm/ImageLazy.min.js",
11
+ "require": "./dist/cjs/ImageLazy.min.js",
12
+ "types": "./dist/types/ImageLazy.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/cjs",
17
+ "dist/esm",
18
+ "dist/types"
19
+ ],
20
+ "sideEffects": false,
8
21
  "scripts": {
9
- "build": "tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json && terser dist/cjs/ImageLazy.js -o dist/cjs/ImageLazy.min.js --compress --mangle && terser dist/esm/ImageLazy.js -o dist/esm/ImageLazy.min.js --compress --mangle"
22
+ "clean": "rimraf dist",
23
+ "build": "npm run clean && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && terser dist/cjs/ImageLazy.js -o dist/cjs/ImageLazy.min.js --compress --mangle && terser dist/esm/ImageLazy.js -o dist/esm/ImageLazy.min.js --compress --mangle"
10
24
  },
11
25
  "keywords": [
12
26
  "react",
13
27
  "lazy-load",
28
+ "lazyload",
14
29
  "image",
15
- "intersection-observer"
30
+ "lazy-image",
31
+ "intersection-observer",
32
+ "performance",
33
+ "react-component",
34
+ "react-images",
35
+ "react-lazy",
36
+ "load-on-scroll",
37
+ "responsive-images",
38
+ "web-optimization",
39
+ "accessibility",
40
+ "a11y",
41
+ "react-hooks",
42
+ "viewport"
16
43
  ],
17
44
  "author": "Percy Chuzon <contacto@percychuzon.com>",
18
- "license": "ISC",
19
- "homepage": "https://github.com/perch33/react-lazy-img-observer",
45
+ "license": "MIT",
46
+ "homepage": "https://imagelazy.percychuzon.com/",
20
47
  "repository": {
21
48
  "type": "git",
22
- "url": "git+https://github.com/perch33/react-lazy-img-observer.git"
49
+ "url": "https://github.com/perch33/react-lazy-img-observer.git"
23
50
  },
24
51
  "bugs": {
25
52
  "url": "https://github.com/perch33/react-lazy-img-observer/issues"
26
53
  },
27
54
  "dependencies": {
28
- "react": "^18.3.1",
29
- "react-dom": "^18.3.1",
30
- "terser": "^5.31.3"
55
+ "terser": "^5.39.2"
56
+ },
57
+ "peerDependencies": {
58
+ "react": ">=17.0.0",
59
+ "react-dom": ">=17.0.0"
31
60
  },
32
61
  "devDependencies": {
33
- "@types/react": "^18.3.3",
34
- "@types/react-dom": "^18.3.0",
35
- "typescript": "^5.5.4"
62
+ "@types/react": "^18.3.21",
63
+ "@types/react-dom": "^18.3.7",
64
+ "rimraf": "^6.0.1",
65
+ "typescript": "^5.8.3"
36
66
  }
37
67
  }
package/src/ImageLazy.tsx DELETED
@@ -1,74 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
-
3
- type ImagesLazy = {
4
- src: string;
5
- alt: string;
6
- width?: number;
7
- height?: number;
8
- id?: number | string;
9
- className?: string;
10
- title?: string;
11
- extraData?: React.ImgHTMLAttributes<HTMLImageElement>;
12
- };
13
-
14
- const ImageLazy = ({
15
- src,
16
- alt,
17
- width,
18
- height,
19
- className,
20
- id,
21
- extraData,
22
- title,
23
- }: ImagesLazy) => {
24
- const imageRef = useRef<HTMLImageElement>(null);
25
- const [isIntersecting, setIsIntersecting] = useState<boolean>(false);
26
-
27
- useEffect(() => {
28
- const observer = new IntersectionObserver(
29
- (entries) => {
30
- entries.forEach((entry) => {
31
- if (entry.isIntersecting) {
32
- setIsIntersecting(true);
33
- if (imageRef.current) {
34
- imageRef.current.src = imageRef.current.dataset.src || "";
35
- }
36
- observer.unobserve(entry.target);
37
- }
38
- });
39
- },
40
- { root: null, rootMargin: "0px", threshold: 0.5 }
41
- );
42
-
43
- if (imageRef.current) {
44
- observer.observe(imageRef.current);
45
- }
46
-
47
- return () => {
48
- if (imageRef.current) {
49
- observer.unobserve(imageRef.current);
50
- }
51
- };
52
- }, [src]);
53
-
54
- return (
55
- <img
56
- title={title}
57
- className={className}
58
- loading="lazy"
59
- ref={imageRef}
60
- data-src={src}
61
- alt={alt}
62
- width={width}
63
- height={height}
64
- style={{
65
- filter: isIntersecting ? "none" : "blur(20px)",
66
- transition: "filter 0.9s",
67
- }}
68
- id={id?.toString()}
69
- {...extraData}
70
- />
71
- );
72
- };
73
-
74
- export default ImageLazy;
package/tsconfig.cjs.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "CommonJS",
5
- "outDir": "dist/cjs"
6
- }
7
- }
package/tsconfig.esm.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "ESNext",
5
- "outDir": "dist/esm"
6
- }
7
- }
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "declaration": true,
6
- "jsx": "react-jsx",
7
- "declarationDir": "dist/types",
8
- "removeComments": true,
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "outDir": "dist",
14
- "moduleResolution": "node"
15
-
16
- },
17
- "include": ["src"],
18
- "exclude": ["node_modules"]
19
- }