smooth-loader 1.2.2 → 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/{.github → .forgejo}/workflows/npm-publish.yml +11 -6
- package/CHANGELOG.md +3 -0
- package/Dockerfile +3 -0
- package/LICENSE +1 -1
- package/README.md +25 -9
- package/compose.yml +1 -3
- package/package.json +2 -2
- package/src/index.ts +26 -26
- package/src/types.ts +1 -1
- package/Containerfile +0 -10
|
@@ -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
package/Dockerfile
ADDED
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,39 +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
9
|
## Contribute
|
|
10
10
|
|
|
11
11
|
### With Container Engine
|
|
12
|
-
> [!NOTE]
|
|
13
|
-
> If you use [🐳 Docker](https://app.docker.com/) instead of [🦦 Podman](https://podman.io/), just replace `podman-compose` with `docker compose`, and `podman` with `docker` in code examples below.
|
|
14
|
-
|
|
15
12
|
#### Build an Image
|
|
16
|
-
To build an image, navigate to the root of the project and run this command
|
|
13
|
+
To build an image, navigate to the root of the project and run this command.
|
|
14
|
+
|
|
15
|
+
With Podman:
|
|
17
16
|
```bash
|
|
18
17
|
podman-compose build
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
With Docker:
|
|
21
|
+
```bash
|
|
22
|
+
docker compose build
|
|
23
|
+
```
|
|
22
24
|
|
|
25
|
+
Now, you'll have an image `smooth-loader` that you can use to create a container.
|
|
23
26
|
|
|
24
27
|
#### Create `node_modules`
|
|
25
|
-
Run this command to install npm packages and generate a `node_modules` directory on your local machine
|
|
28
|
+
Run this command to install npm packages and generate a `node_modules` directory on your local machine.
|
|
26
29
|
|
|
30
|
+
With Podman:
|
|
27
31
|
```bash
|
|
28
32
|
podman-compose run --rm app npm i
|
|
29
33
|
```
|
|
30
34
|
|
|
35
|
+
With Docker:
|
|
36
|
+
```bash
|
|
37
|
+
docker compose run --rm app npm i
|
|
38
|
+
```
|
|
39
|
+
|
|
31
40
|
#### Create and Enter the Container
|
|
32
|
-
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:
|
|
33
44
|
```bash
|
|
34
45
|
podman-compose run --rm app sh
|
|
35
46
|
```
|
|
36
47
|
|
|
48
|
+
With Docker:
|
|
49
|
+
```bash
|
|
50
|
+
docker compose run --rm app sh
|
|
51
|
+
```
|
|
52
|
+
|
|
37
53
|
You'll be able to run NPM commands inside of the container and commands:
|
|
38
54
|
- `npm run watch` to make TypeScript watch for your changes and auto-compile everything to plain JavaScript
|
|
39
55
|
- `npm run build` compile all of your TypeScript files to JavaScript
|
package/compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
11
|
"typescript": "^5.9.3"
|
|
12
12
|
},
|
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