
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
@cher-ami/smooth-scroll
Advanced tools
A smooth scroll library
Uses Signal
$ npm i @cher-ami/smooth-scroll
const container = querySelector("#scroll-container")
const scrollManager = new SmoothScrollManager(container)
scrollManager.init()
<div data-scroll-section></div>
To be counted in scroll flow, each element in container
must be declared
Member | Type | Description |
---|---|---|
progress | number | Percentage of scroll progress |
scrollPosition | number | Current scroll position in px (lerped value) |
scrollDestination | number | Scroll destination in px (raw value) |
scrollLength | number | Total scrollable length |
scrollSpeed | number | Current speed |
Method | Params | Description |
---|---|---|
init() | none | Initialise scroll |
scrollToTop(speed?) | speed : number = 200 | Scroll to position 0 |
scrollToBottom(speed?) | speed : number = 200 | Scroll to max position |
scrollTo(target) | target : number | HTMLDivElement | Scroll to destination in px or given HTML element |
disable() | none | Disable scroll |
enable() | none | Enable scroll |
kill() | none | Cancel RAF and remove listeners |
refresh() | none | Update scroll sections and scroll length, should be called if the content of the scroll container has changed (ex: after page transitions) |
Wrap your app with <SmoothContainer />
export function App () {
return (
<div className={"root"}>
<SmoothContainer>
{/** ... */}
</SmoothContainer>
</div>
)
}
Children will have access to scrollManager
instance via ScrollContext
const scrollManager = useContext(ScrollContext)
Components :
<SmoothContainer />
Wrap all your scroll contentHooks :
useScrollPosition
Will be called every time scroll position changesuseScrollSpeed
Will be called every time scroll speed changesDispatch scrollContext to children and give them access to API
<SmoothContainer>
{/** ... */}
</SmoothContainer>
Props :
none
Execute callback every time scroll position changes
useScrollPosition((scrollPosition: number) => {
// Do something
}, []);
Parameters :
(scrollPositionValue:number) => void
Callback function to execute each time the scroll position changesany[] = []
Additional react dependanciesReturns :
nothing
Execute callback every time scroll speed changes
useScrollSpeed((scrollSpeed: number) => {
// Do something
}, []);
Parameters :
(scrollSpeedValue:number) => void
Callback function to execute each time the scroll speed changesany[] = []
Additional react dependanciesReturns :
nothing
FAQs
Smooth scrool engine
The npm package @cher-ami/smooth-scroll receives a total of 0 weekly downloads. As such, @cher-ami/smooth-scroll popularity was classified as not popular.
We found that @cher-ami/smooth-scroll demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.