ScrollProgressJS is a lightweight JavaScript library that creates a customizable scroll progress indicator for web pages. It allows you to display a visual progress bar indicating how much of the page has been scrolled.
data-autoload
attribute is set.You can include ScrollProgressJS in your project via CDN, npm, or by downloading the script:
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/ScrollProgressJS@main/ScrollProgress.js"></script>
npm install scroll-progress-indicator
To initialize ScrollProgressJS with default settings:
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/ScrollProgressJS@main/ScrollProgress.js" data-autoload="true"></script>
You can also customize the progress bar with your own configurations:
<script src="scrollprogress.js"></script>
<script>
// Custom initialization
ScrollProgress.init({
color: '#ff5722', // Progress bar color
height: '4px', // Progress bar height
position: 'bottom' // Progress bar position ('top' or 'bottom')
});
</script>
After initialization, you can update the configuration:
ScrollProgress.setConfig({
color: 'hotpink', // Updated color
height: '4px', // Updated height
position: 'top' // Updated position
});
To remove the ScrollProgressJS and stop listening for scroll events:
ScrollProgress.destroy();
You can specify the element to track for scroll progress using its selector:
ScrollProgress.setScrollElement('.article'); // Example: Track scroll progress of the .article element
You can also use ScrollProgressJS in Node.js applications:
Install the library using npm:
npm install scroll-progress-indicator
// Import ScrollProgress
const ScrollProgress = require('scroll-progress-indicator');
// Initialize
ScrollProgress.init();
// Update configuration (example)
ScrollProgress.setConfig({
color: '#ff0000',
height: '6px',
position: 'bottom'
});
// Destroy
ScrollProgress.destroy();
<!-- Auto-initialize with default settings -->
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/ScrollProgressJS@main/ScrollProgress.js" data-autoload="true"></script>
<!-- Custom initialization -->
<script src="scrollprogress.js"></script>
<script>
ScrollProgress.init({
color: '#007bff', // Blue color
height: '3px', // 3px height
position: 'bottom' // Progress bar at the bottom
});
</script>
Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.
git checkout -b feature/AmazingFeature
)git commit -am 'Add some feature'
)git push origin feature/AmazingFeature
)Please make sure to update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, suggestions, or feedback, please create an issue.
Made with ❤️ by SH20RAJ