1.0.0 • Published 7 months ago

parallax-scrolling v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Parallax Scrolling

A lightweight JavaScript library for adding a smooth parallax scrolling effect to elements.

🚀 Features

  • 📜 Simple API – Easily apply parallax effects to any HTML element.
  • Lightweight – No dependencies, just pure JavaScript.

📦 Installation

Install via npm:

npm install parallax-scrolling

🎯 Usage

1. Init

import ParallaxLayer from "parallax-scrolling";
// or
const ParallaxLayer = require("parallax-scrolling");

const parallax = new ParallaxLayer(); 

2. Use it

const element = document.getElementById("parallax-item");

parallax.createLayer(element, { type: "translate", layer: 2, direction: "top" });
parallax.start();

📜 API Reference

new Parallax(options)
Option | Type | Default | Description --- | --- | --- | --- | translate | number | 0.5 | Adjusts the parallax translation speed scale | number | 0.005 | Adjusts the scaling effect

parallax.createLayer(dom, options = { type, layer, direction, unit })
Registers an element for the parallax effect.

ParameterTypeDefaultDescription
domHTMLElementRequiredThe element to apply the effect on
type"translate", "scale"RequiredThe effect type
layernumberRequiredThe depth of the layer (higher values = slower movement)
direction"Top", "Left", "Right", "Bottom"-The direction of movement
unitstring"px"The CSS unit (px, %, em, etc.)

parallax.start()
Starts the parallax effect (listens for scroll events).

parallax.stop()
Stops the parallax effect.


🌎 Browser Support

Works in all modern browsers (Chrome, Firefox, Edge, Safari).


📜 License

This project is licensed under the MIT License by default.


🙌 Contributing

Contributions are welcome! If you'd like to improve this project:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Commit your changes (git commit -m "Add new feature")
  4. Push to the branch (git push origin feature-name)
  5. Open a Pull Request

📬 Contact

1.0.0

7 months ago