
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
scroll-concert
Advanced tools
A TS library to automatically synchronize scroll events between DOM elements.
Scroll Concert is a lightweight JavaScript library designed to effortlessly sync scroll positions across multiple elements on your page. If you need synchronized scrolling behavior, Scroll Concert makes it easy to keep your scrollable elements in harmony. It is ideal to create parallax effects.
npm i scroll-concert
or
yarn add scroll-concert
After installation, simply include the library in your project and call scrollConcert
to sync scroll positions between your elements.
import scrollConcert from "scroll-concert";
// Sync one leader with a follower
scrollConcert({
leader: "#leader", // The selector for your leader element(s)
follower: [{ selector: "#follower" }], // The selector for your follower(s)
});
scrollConcert({
leader: ["#leader", "#secondLeader"], // Multiple leaders
follower: [{ selector: "#follower" }], // One follower
});
Control the speed of your followers with a speedRatio
. For example, if you want your follower to scroll twice as fast as the leader:
scrollConcert({
leader: "#leader",
follower: [
{ selector: "#followerA", speedRatio: 2 }, // Follower scrolls twice as fast
{ selector: "#followerB", speedRatio: 3 }, // Follower scrolls thrice as fast
],
});
scrollConcert returns a function you can call to top synchronization:
const stopTheMusic = scrollConcert({
leader: "#leader",
follower: [{ selector: "#follower" }],
});
// Later, when you want to stop the synchronization:
stopTheMusic();
Scroll Concert automatically handles edge cases like when an element is not scrollable or when scrollHeight
is equal to clientHeight
. No unnecessary scrolling will occur, ensuring a smooth user experience.
export type Leader = string | string[];
export type Follower = {
selector: string;
speedRatio?: number;
};
export type ConcertParams = {
leader: Leader; // The leader element(s) (id, class, or selector)
follower: Follower | Follower[]; // The follower element(s)
};
function scrollConcert(params: ConcertParams): () => void; // Returns a stop function
To run the tests locally:
npm i
npm run test
You can also test manually with the index.html provided in the project, which has a simple parallax implementation.Scroll Concert uses Vitest for unit tests, to ensure the library works in various scenarios.
We welcome contributions to make this library even better! Feel free to fork the repository, make changes, and submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A TS library to automatically synchronize scroll events between DOM elements.
We found that scroll-concert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.