Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
smoothscroll-polyfill
Advanced tools
The smoothscroll-polyfill package provides a polyfill for the smooth scrolling behavior in browsers that do not support it natively. This allows developers to ensure a consistent smooth scrolling experience across different browsers.
Polyfill Initialization
This code initializes the smoothscroll-polyfill, enabling smooth scrolling behavior in browsers that do not support it natively.
require('smoothscroll-polyfill').polyfill();
Smooth Scrolling to an Element
This code demonstrates how to smoothly scroll to a specific element on the page using the scrollIntoView method with the 'smooth' behavior option.
document.querySelector('#targetElement').scrollIntoView({ behavior: 'smooth' });
Smooth Scrolling to a Position
This code shows how to smoothly scroll to a specific position on the page using the window.scroll method with the 'smooth' behavior option.
window.scroll({ top: 1000, left: 0, behavior: 'smooth' });
The seamless-scroll-polyfill package provides a similar polyfill for smooth scrolling behavior. It aims to offer a seamless experience for smooth scrolling across different browsers, much like smoothscroll-polyfill.
The scroll-behavior-polyfill package also provides a polyfill for the CSSOM View Module's scroll-behavior property, enabling smooth scrolling in browsers that do not support it natively. It is another alternative to smoothscroll-polyfill.
The Scroll Behavior specification has been introduced as an extension of the Window
interface to allow for the developer to opt in to native smooth scrolling. To date this has only been implemented in Firefox.
See it in action https://iamdustan.github.io/smoothscroll
Download the distribution file from this repository and include it in your project.
You can also find it in npm as smoothscroll-polyfill or bower as smoothscroll.
require('smoothscroll-polyfill').polyfill();
Requires requestAnimationFrame polyfill for browsers which don't support it!
Fork the repository and run npm install.
After any modification make sure it doesn't break in any of the supported browsers, check linting and build running npm run build and then open a pull request.
Successfully tested in:
If you have tested this and worked as expected in a different browser let us know so we can add it to the list, if not open an issue providing browser, browser version and a good description about it.
FAQs
Smooth Scroll behavior polyfill
We found that smoothscroll-polyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.