smooth-loader 1.2.2 → 1.2.4

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.
@@ -1,23 +1,30 @@
1
1
  name: Publish package to NPM
2
+ enable-email-notifications: true
2
3
 
3
4
  # Good article: https://medium.com/@codewithwaheed/publish-your-first-package-using-npm-and-github-actions-e453ca9f9fd2
4
5
 
5
6
  on:
6
7
  push:
7
- branches: master
8
+ branches: [master]
8
9
 
9
10
  jobs:
10
11
  publish:
11
- runs-on: ubuntu-latest
12
+ runs-on: burn
13
+ name: Publish to NPM registry
12
14
  steps:
13
- - uses: actions/checkout@v2
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
14
17
 
15
18
  - name: Setup Node.js
16
- uses: actions/setup-node@v2
19
+ uses: https://github.com/actions/setup-node@v2
17
20
  with:
18
21
  node-version: '20'
19
22
  registry-url: 'https://registry.npmjs.org/'
20
- - run: npm install
21
- - run: npm publish
23
+
24
+ - name: Install Deps
25
+ run: npm install
26
+
27
+ - name: Publish Library
28
+ run: npm publish
22
29
  env:
23
30
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,51 +1,72 @@
1
1
  # Release Notes
2
2
 
3
+ ## v1.2.4 (2026-08-13)
4
+
5
+ - Improved forgejo action workflow file
6
+
7
+ ## v1.2.3 (2026-08-11)
8
+
9
+ - Moved from GitHub to Codeberg
10
+
3
11
  ## v1.2.2 (2025-11-30)
12
+
4
13
  - Upgraded TypeScript to the latest version.
5
14
  - Updated `README.md` file by adding more info.
6
15
 
7
16
  ## v1.2.1 (2025-06-29)
17
+
8
18
  - Removed not needed lines from Dockerfile and docker-compose.yml.
9
19
 
10
20
  ## v1.2.0 (2025-06-29)
21
+
11
22
  - Added container engines support like Podman and Docker to the project.
12
23
 
13
24
  ## v1.1.4 (2024-04-08)
25
+
14
26
  - Formatted the `CHANGELOG.md` file.
15
27
  - Refactored the code to make it more readable.
16
28
  - Improved error handling.
17
29
 
18
30
  ## v1.1.3 (2023-11-19)
31
+
19
32
  - Changed the `README.MD` file.
20
33
 
21
34
  ## v1.1.2 (2022-12-04)
35
+
22
36
  - Removed line from docs.
23
37
 
24
38
  ## v1.1.1 (2022-12-04)
39
+
25
40
  - Code refactoring.
26
41
  - Added ability to provide array of images instead of only `NodeListOf`.
27
42
  - Improved documentation in `README.md`.
28
43
 
29
44
  ## v1.1.0 (2022-12-01)
45
+
30
46
  - Moved from beta version.
31
47
 
32
48
  ## v1.1.0-beta.2 (2022-11-30)
49
+
33
50
  - Code refactoring.
34
51
  - Manual testing.
35
52
 
36
53
  ## v1.1.0-beta.1 (2022-11-29)
54
+
37
55
  - Removed blur from small placeholder images if they are set with `src` attribute.
38
56
  - Added more info to docs.
39
57
 
40
58
  ## v1.1.0-beta.0 (2022-11-29)
59
+
41
60
  - Added missing information to the `README.md` file.
42
61
  - Added ability to show small images as placeholder, so you don't look at empty screen but blurred mini version of the image.
43
62
 
44
63
  ## v1.0.7 (2022-06-22)
64
+
45
65
  - Fixed appearing transition with background images. Now it works.
46
66
  - Improved documentation `README.md` file.
47
67
  - Added **configurations** for smooth loading images.
48
68
 
49
69
  ## v1.0.6 (2022-01-02)
70
+
50
71
  - Changed default images selector to be more specific.
51
72
  - Added `CHANGELOG.md` file.
package/Dockerfile ADDED
@@ -0,0 +1,3 @@
1
+ FROM node:24-alpine
2
+
3
+ WORKDIR /app
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Sergey Chornenkyi (Serhii Cho)
3
+ Copyright (c) 2021 Serhii Cho
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,39 +1,55 @@
1
- ![Smooth loader logo](https://smooth-loader.github.io/images/logo.png)
1
+ ![Smooth loader logo](https://smooth-loader.codeberg.page/images/logo.png)
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.github.io) for all the details
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
- Now, you'll have an image `smooth-loader` that you can use to create a container.
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
@@ -4,8 +4,6 @@ services:
4
4
  app:
5
5
  image: smooth-loader
6
6
  container_name: smooth-loader
7
- build:
8
- context: .
9
- dockerfile: Containerfile
7
+ build: .
10
8
  volumes:
11
9
  - .:/app:z
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "smooth-loader",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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.github.io",
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
- const images = getImagesElements(selector)
5
+ const images = getImagesElements(selector)
6
6
 
7
- if (!images) {
8
- return
9
- }
7
+ if (!images) {
8
+ return
9
+ }
10
10
 
11
- const configurations = config || {
12
- root: null,
13
- threshold: 0,
14
- }
11
+ const configurations = config || {
12
+ root: null,
13
+ threshold: 0,
14
+ }
15
15
 
16
- return observerCreator(images, configurations)
16
+ return observerCreator(images, configurations)
17
17
  }
18
18
 
19
19
  function getImagesElements(selector?: InputTypes): ImageElement[] {
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
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
@@ -1,4 +1,4 @@
1
1
  export type ImageElement = HTMLDivElement | HTMLImageElement
2
2
  export type InputTypes = NodeListOf<ImageElement> | ImageElement[] | string
3
3
 
4
- export interface Config extends IntersectionObserverInit { }
4
+ export interface Config extends IntersectionObserverInit { }
package/Containerfile DELETED
@@ -1,10 +0,0 @@
1
- FROM node:24-alpine
2
-
3
- WORKDIR /app
4
-
5
- COPY package*.json .
6
-
7
- RUN npm install && \
8
- npm cache clean --force
9
-
10
- COPY . .