Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
scrollbooster
Advanced tools
Enjoyable content drag-to-scroll micro (~2KB gzipped) library.
You can install it via npm
package manager or just drop a script
tag:
npm i scrollbooster
<script src="https://unpkg.com/scrollbooster@1.0.3/dist/scrollbooster.min.js"></script>
import ScrollBooster from 'scrollbooster'
let sb = new ScrollBooster({
viewport: document.querySelector('.viewport') // required
// ...other options
})
Option | Type | Default | Description |
---|---|---|---|
viewport | element | null | Viewport - outer element |
content | element | First child of viewport element | Scrollable content inside viewport |
handle | element | Viewport element | Element that respond to drag event |
bounce | boolean | true | Inertia bounce effect (scroll past viewport borders) |
friction | float | 0.05 | Scroll friction factor (scroll inertia after pointer release) |
bounceForce | float | 0.1 | Bounce effect factor |
emulateScroll | boolean | false | Emulate viewport mouse wheel events (for cases when scrolling with transform property) |
onUpdate | function | noop | User function that updates element properties according to received coordinates (see demo examples). Receives object with properties: position , viewport and content . Each property contains metrics to perform an actual scrolling |
Method | Description |
---|---|
setPosition | Sets new scroll position in viewport. Receives an object with properties x and y |
updateMetrics | Updates element sizes. Useful for images loading or other dynamic content |
getUpdate | Returns current metrics and coordinates in a same format as onUpdate |
destroy | Destroys all instance's event listeners |
let viewport = document.querySelector('.viewport')
let content = document.querySelector('.viewport-content')
let sb = new ScrollBooster({
viewport: viewport,
content: content,
handle: document.querySelector('.viewport-scroller'),
bounce: true,
emulateScroll: false,
onUpdate: (data)=> {
content.style.transform = `translate(
${-data.position.x}px,
${-data.position.y}px
)`
// and also metrics: data.viewport['width'|'height'] and data.cotent['width'|'height']
}
})
// methods example:
sb.updateMetrics()
sb.setPosition({
x: 100,
y: 100
})
sb.destroy()
ScrollBooster has been tested in IE 11, Edge and other modern browsers (Chrome, Firefox, Safari).
David DeSandro for his talk "Practical UI Physics".
MIT License (c) Ilya Shubin
FAQs
Enjoyable content drag-to-scroll library
The npm package scrollbooster receives a total of 12,764 weekly downloads. As such, scrollbooster popularity was classified as popular.
We found that scrollbooster 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.