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 CHANGED
@@ -1,3 +1,8 @@
1
1
  node_modules
2
2
  .vscode
3
3
  .git
4
+ .github
5
+ .gitignore
6
+ .prettierrc
7
+ LICENSE
8
+ *.md
@@ -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: ubuntu-latest
11
+ runs-on: burn
12
12
  steps:
13
- - uses: actions/checkout@v2
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
- - run: npm install
21
- - run: npm publish
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 Docker support to the project
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
@@ -1,11 +1,3 @@
1
1
  FROM node:24-alpine
2
2
 
3
3
  WORKDIR /app
4
-
5
- COPY package.json .
6
-
7
- RUN npm install
8
-
9
- COPY . .
10
-
11
- ENTRYPOINT ["sh"]
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,41 +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
- ## Development
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
- #### Install Dependencies
14
- ```bash
15
- npm i
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
- #### Watch File Changes
19
- This command will watch for your changes and compile TypeScript to JavaScript files into `lib/js`
15
+ With Podman:
20
16
  ```bash
21
- npm run watch
17
+ podman-compose build
22
18
  ```
23
19
 
24
- ### With [Docker](https://www.docker.com/)
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
@@ -4,8 +4,6 @@ services:
4
4
  app:
5
5
  image: smooth-loader
6
6
  container_name: smooth-loader
7
- build:
8
- context: .
7
+ build: .
9
8
  volumes:
10
- - .:/app
11
- - /app/node_modules
9
+ - .:/app:z
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "smooth-loader",
3
- "version": "1.2.1",
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.github.io",
9
+ "homepage": "https://smooth-loader.codeberg.page",
10
10
  "devDependencies": {
11
- "typescript": "^5.8.3"
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
- 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 { }