smooth-loader 1.2.1 → 1.2.3
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/.dockerignore +5 -0
- package/{.github → .forgejo}/workflows/npm-publish.yml +11 -6
- package/CHANGELOG.md +29 -22
- package/Dockerfile +0 -8
- package/LICENSE +1 -1
- package/README.md +32 -18
- package/{docker-compose.yml → compose.yml} +2 -4
- package/package.json +4 -4
- package/src/index.ts +26 -26
- package/src/types.ts +1 -1
package/.dockerignore
CHANGED
|
@@ -4,20 +4,25 @@ name: Publish package to NPM
|
|
|
4
4
|
|
|
5
5
|
on:
|
|
6
6
|
push:
|
|
7
|
-
branches: master
|
|
7
|
+
branches: [master]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
publish:
|
|
11
|
-
runs-on:
|
|
11
|
+
runs-on: burn
|
|
12
12
|
steps:
|
|
13
|
-
-
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
14
15
|
|
|
15
16
|
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@v2
|
|
17
|
+
uses: https://github.com/actions/setup-node@v2
|
|
17
18
|
with:
|
|
18
19
|
node-version: '20'
|
|
19
20
|
registry-url: 'https://registry.npmjs.org/'
|
|
20
|
-
|
|
21
|
-
-
|
|
21
|
+
|
|
22
|
+
- name: Install Deps
|
|
23
|
+
run: npm install
|
|
24
|
+
|
|
25
|
+
- name: Publish Library
|
|
26
|
+
run: npm publish
|
|
22
27
|
env:
|
|
23
28
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,47 +1,54 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
+
## v1.2.3 (2026-08-11)
|
|
4
|
+
- Moved from GitHub to Codeberg
|
|
5
|
+
|
|
6
|
+
## v1.2.2 (2025-11-30)
|
|
7
|
+
- Upgraded TypeScript to the latest version.
|
|
8
|
+
- Updated `README.md` file by adding more info.
|
|
9
|
+
|
|
3
10
|
## v1.2.1 (2025-06-29)
|
|
4
|
-
- Removed not needed lines from Dockerfile and docker-compose.yml
|
|
11
|
+
- Removed not needed lines from Dockerfile and docker-compose.yml.
|
|
5
12
|
|
|
6
13
|
## v1.2.0 (2025-06-29)
|
|
7
|
-
- Added
|
|
14
|
+
- Added container engines support like Podman and Docker to the project.
|
|
8
15
|
|
|
9
16
|
## v1.1.4 (2024-04-08)
|
|
10
|
-
- Formatted the `CHANGELOG.md` file
|
|
11
|
-
- Refactored the code to make it more readable
|
|
12
|
-
- Improved error handling
|
|
17
|
+
- Formatted the `CHANGELOG.md` file.
|
|
18
|
+
- Refactored the code to make it more readable.
|
|
19
|
+
- Improved error handling.
|
|
13
20
|
|
|
14
21
|
## v1.1.3 (2023-11-19)
|
|
15
|
-
- Changed the `README.MD` file
|
|
22
|
+
- Changed the `README.MD` file.
|
|
16
23
|
|
|
17
24
|
## v1.1.2 (2022-12-04)
|
|
18
|
-
- Removed line from docs
|
|
25
|
+
- Removed line from docs.
|
|
19
26
|
|
|
20
27
|
## v1.1.1 (2022-12-04)
|
|
21
|
-
- Code refactoring
|
|
22
|
-
- Added ability to provide array of images instead of only NodeListOf
|
|
23
|
-
- Improved documentation in `README.md
|
|
28
|
+
- Code refactoring.
|
|
29
|
+
- Added ability to provide array of images instead of only `NodeListOf`.
|
|
30
|
+
- Improved documentation in `README.md`.
|
|
24
31
|
|
|
25
32
|
## v1.1.0 (2022-12-01)
|
|
26
|
-
- Moved from beta version
|
|
33
|
+
- Moved from beta version.
|
|
27
34
|
|
|
28
35
|
## v1.1.0-beta.2 (2022-11-30)
|
|
29
|
-
- Code refactoring
|
|
30
|
-
- Manual testing
|
|
36
|
+
- Code refactoring.
|
|
37
|
+
- Manual testing.
|
|
31
38
|
|
|
32
39
|
## v1.1.0-beta.1 (2022-11-29)
|
|
33
|
-
- Removed blur from small placeholder images if they are set with `src` attribute
|
|
34
|
-
- Added more info to docs
|
|
40
|
+
- Removed blur from small placeholder images if they are set with `src` attribute.
|
|
41
|
+
- Added more info to docs.
|
|
35
42
|
|
|
36
43
|
## v1.1.0-beta.0 (2022-11-29)
|
|
37
|
-
- Added missing information to the README.md file
|
|
38
|
-
- Added ability to show small images as placeholder, so you don't look at empty screen but blurred mini version of the image
|
|
44
|
+
- Added missing information to the `README.md` file.
|
|
45
|
+
- Added ability to show small images as placeholder, so you don't look at empty screen but blurred mini version of the image.
|
|
39
46
|
|
|
40
47
|
## v1.0.7 (2022-06-22)
|
|
41
|
-
- Fixed appearing transition with background images. Now it works
|
|
42
|
-
- Improved documentation `README.md` file
|
|
43
|
-
- Added **configurations** for smooth loading images
|
|
48
|
+
- Fixed appearing transition with background images. Now it works.
|
|
49
|
+
- Improved documentation `README.md` file.
|
|
50
|
+
- Added **configurations** for smooth loading images.
|
|
44
51
|
|
|
45
52
|
## v1.0.6 (2022-01-02)
|
|
46
|
-
- Changed default images selector to be more specific
|
|
47
|
-
- Added `CHANGELOG.md` file
|
|
53
|
+
- Changed default images selector to be more specific.
|
|
54
|
+
- Added `CHANGELOG.md` file.
|
package/Dockerfile
CHANGED
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,41 +1,55 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
Smooth loader allows you smoothly lazy load images and background images. Lazy Loading defers the loading of an image that is not needed on the page immediately. An image, not visible to the user when the page loads, is loaded later when the user scrolls and the image actually becomes visible. If the user never scrolls, an image that is not visible to the user never gets loaded.
|
|
4
4
|
|
|
5
5
|
This package is a MUST-HAVE for every website containing multiple images on the page. It's surely the best lazy loading package on NPM that you can configure to your own needs.
|
|
6
6
|
|
|
7
|
-
## Follow the [official documentation](https://smooth-loader.
|
|
7
|
+
## Follow the [official documentation](https://smooth-loader.codeberg.page) for all the details
|
|
8
8
|
|
|
9
|
-
##
|
|
10
|
-
### Without Docker
|
|
11
|
-
You'll need to have [Node JS and NPM](https://nodejs.org/en/download) installed on your machine to run it locally.
|
|
9
|
+
## Contribute
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
11
|
+
### With Container Engine
|
|
12
|
+
#### Build an Image
|
|
13
|
+
To build an image, navigate to the root of the project and run this command.
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
This command will watch for your changes and compile TypeScript to JavaScript files into `lib/js`
|
|
15
|
+
With Podman:
|
|
20
16
|
```bash
|
|
21
|
-
|
|
17
|
+
podman-compose build
|
|
22
18
|
```
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
#### Build the Image
|
|
26
|
-
To build an image, navigate to the root of the project that contains `Dockerfile` and run this command:
|
|
20
|
+
With Docker:
|
|
27
21
|
```bash
|
|
28
22
|
docker compose build
|
|
29
23
|
```
|
|
30
24
|
|
|
31
25
|
Now, you'll have an image `smooth-loader` that you can use to create a container.
|
|
32
26
|
|
|
27
|
+
#### Create `node_modules`
|
|
28
|
+
Run this command to install npm packages and generate a `node_modules` directory on your local machine.
|
|
29
|
+
|
|
30
|
+
With Podman:
|
|
31
|
+
```bash
|
|
32
|
+
podman-compose run --rm app npm i
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
With Docker:
|
|
36
|
+
```bash
|
|
37
|
+
docker compose run --rm app npm i
|
|
38
|
+
```
|
|
39
|
+
|
|
33
40
|
#### Create and Enter the Container
|
|
34
|
-
To create and enter inside the container, run this command
|
|
41
|
+
To create and enter inside the container, run this command.
|
|
42
|
+
|
|
43
|
+
With Podman:
|
|
44
|
+
```bash
|
|
45
|
+
podman-compose run --rm app sh
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
With Docker:
|
|
35
49
|
```bash
|
|
36
|
-
docker compose run --rm app
|
|
50
|
+
docker compose run --rm app sh
|
|
37
51
|
```
|
|
38
52
|
|
|
39
53
|
You'll be able to run NPM commands inside of the container and commands:
|
|
40
54
|
- `npm run watch` to make TypeScript watch for your changes and auto-compile everything to plain JavaScript
|
|
41
|
-
- `npm run build` compile all of your TypeScript files to JavaScript
|
|
55
|
+
- `npm run build` compile all of your TypeScript files to JavaScript
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smooth-loader",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "This package allows you to lazy load your images using IntersectionObserver technology. It supports loading background images as well as the regular images with img tag.",
|
|
5
5
|
"main": "lib/js/index.js",
|
|
6
6
|
"types": "lib/js",
|
|
7
7
|
"author": "Serhii Cho",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"homepage": "https://smooth-loader.
|
|
9
|
+
"homepage": "https://smooth-loader.codeberg.page",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"typescript": "^5.
|
|
11
|
+
"typescript": "^5.9.3"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc -p .",
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
"lazy loading",
|
|
22
22
|
"background image"
|
|
23
23
|
]
|
|
24
|
-
}
|
|
24
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,36 +2,36 @@ import observerCreator from './observerCreator'
|
|
|
2
2
|
import { Config, ImageElement, InputTypes } from './types'
|
|
3
3
|
|
|
4
4
|
export default (selector?: InputTypes, config?: Config): void => {
|
|
5
|
-
|
|
5
|
+
const images = getImagesElements(selector)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!images) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const configurations = config || {
|
|
12
|
+
root: null,
|
|
13
|
+
threshold: 0,
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return observerCreator(images, configurations)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function getImagesElements(selector?: InputTypes): ImageElement[] {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
if (!selector) {
|
|
21
|
+
const elements = document.querySelectorAll<ImageElement>(
|
|
22
|
+
'.smooth-loader[data-src]',
|
|
23
|
+
)
|
|
24
|
+
return Array.from(elements)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof selector === 'string') {
|
|
28
|
+
const elements = document.querySelectorAll<ImageElement>(selector)
|
|
29
|
+
return Array.from(elements)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (selector instanceof NodeList) {
|
|
33
|
+
return Array.from(selector)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return selector
|
|
37
37
|
}
|
package/src/types.ts
CHANGED