
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
lit-scroll
Advanced tools
Install it from NPM:
npm i lit-scroll
The library uses a ResizeObserver
(conditionally) to listen to scrollable element size change. In order to support dynamic scrollable container size change in Safari and IE, you should use ResizeObserver
polyfill.
IMPORTANT: The library's default compilation target is ES6. If you need to support ES5 environments - consider transpiling it.
In your HTML:
<body>
<div data-lit-scroll="wrapper">
<div data-lit-scroll="container">
<!-- Layout here -->
</div>
</div>
</body>
Note: wrapper element must be a descendant of <body>
.
In your JS:
import createLitScroll from 'lit-scroll';
const scroll = createLitScroll({
// defaults
ease: 0.1,
mobile: false,
});
If your page is quite long, you can split your scroll container into scroll sections (via [data-lit-scroll="section"]
attribute) to improve scrolling performance. This technique requires IntersectionObserver
support. If none will be detected - [data-lit-scroll="section"] attribute will simply have no effect, nothing will break.
Syntax:
<body>
<div data-lit-scroll="wrapper">
<div data-lit-scroll="container">
<div data-lit-scroll="section">
<!-- Section content goes here -->
</div>
<div data-lit-scroll="section">
<!-- Section content goes here -->
</div>
<!-- ...and so on -->
</div>
</div>
</body>
Option | Default | Description |
---|---|---|
ease | 0.1 | Number. Configures linear interpolation "strength". |
mobile | true | Boolean. Indicates whether or not library should take over native scroll on mobile devices |
Method | Parameters | Description |
---|---|---|
on | (event: 'scroll', fn: Function) | Add a scroll listener, which executes a specified function on every scroll change. Callback parameters: docScrollValue (current browser scroll value), scrollValue (current interpolated value), maxHeight (max scroll height), speed (positive if scrolling down, negative otherwise). |
off | (event: 'scroll', fn: Function) | Remove a scroll listener |
scrollTo | (target: (string | number |
getCurrentValue | none | Get current document scroll value |
getCurrentLerpValue | none | Get current lerp scroll value |
getSpeed | none | Get current speed value |
disable | none | Disable scrolling |
enable | none | Enable scrolling |
isEnabled | none | Get scroll lock state. Returns boolean value. scrolling |
destroy | none | Destroy an instance |
FAQs
JS smooth scrolling library
The npm package lit-scroll receives a total of 18 weekly downloads. As such, lit-scroll popularity was classified as not popular.
We found that lit-scroll demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.