Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@braid/rafscroll
Advanced tools
Rafscroll is a small library (<3kb
esm or <4kb
umd) to smooth scroll windows and
DOM elements by using a browser’s native requestAnimationFrame
, ensuring
optimal scrolling without impacting site performance. Rafscroll can operate on
both the x and y axis with various easing functions.
Note: This readme assumes you are using a build tool like webpack
First install from NPM or yarn:
npm install @braid/rafscroll
- or -
yarn add @braid/rafscroll
Then import/require the library in your front end code:
// main.js
import rafscroll from '@braid/rafscroll'
Rafscroll exports a function. Calling this function creates a new instance of rafscroll.
let scroller = rafscroll(element, {...options})
The returned object can then have it's X or Y axis animated by calling
scrollTop()
or/and scrollLeft()
. The return value of either of these
is a Promise
that resolves when the scroll animation is complete.
For convenience rafscroll also uses some intelligent defaults — the window is
the default element, and the the default easing is quadratic.
A full example:
import rafscroll from '@braid/rafscroll'
// Scroll 100px down the page after 1 second.
setTimeout(async () => {
await rafscroll().scrollTop(100)
alert('Finished scrolling')
}, 1000)
Available options to pass as a second argument to rafscroll:
Option | Values | Default |
---|---|---|
duration | any Number in milliseconds | 500 |
easing | 'quadratic', 'linear', or a custom Function | 'quadratic' |
Custom easing functions receive an object containing 4 properties:
{current, duration, posDelta, posStart}
They should return a numeric value representing the current position. For example the linear easing function already included in rafscroll is:
function ({current, duration, posDelta, posStart}) {
return (current / duration) * posDelta + posStart
}
Rafscroll is written and maintained by Braid LLC, and offered freely under an MIT license.
FAQs
Eased scrolling (smooth scroll) using requestAnimationFrame
The npm package @braid/rafscroll receives a total of 2 weekly downloads. As such, @braid/rafscroll popularity was classified as not popular.
We found that @braid/rafscroll demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.