
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
sweet-scroll
Advanced tools
Modern and the sweet smooth scroll library.
requestAnimationFrame
API (IE9 works in setTimeout
instead)$ npm install sweet-scroll
import SweetScroll from "sweet-scroll"
<script src="sweet-scroll.min.js"></script>
<a href="#intro" data-scroll>Go to Introduction</a>
...
<div id="intro">Introduction</div>
const sweetScroll = new SweetScroll({/* some options */});
The following options are applied by default. It can be customized as needed.
{
trigger: "[data-scroll]", // Selector for trigger (must be a valid css selector)
header: "[data-scroll-header]", // Selector for fixed header (must be a valid css selector)
duration: 1000, // Specifies animation duration in integer
delay: 0, // Specifies timer for delaying the execution of the scroll in milliseconds.
easing: "easeOutQuint", // Specifies the pattern of easing
offset: 0, // Specifies the value to offset the scroll position in pixels
verticalScroll: true, // Enable the vertical scroll
horizontalScroll: false, // Enable the horizontal scroll
stopScroll: true, // When fired wheel or touchstart events to stop scrolling
stopPropagation: true, // Stop the bubbling of trigger element click events
// Callbacks
beforeScroll: null,
afterScroll: null,
cancelScroll: null
}
Supports the following easing.
linear
easeInQuad
easeOutQuad
easeInOutQuad
easeInCubic
easeOutCubic
easeInOutCubic
easeInQuart
easeOutQuart
easeInOutQuart
easeInQuint
easeOutQuint
(default)easeInOutQuint
easeInSine
easeOutSine
easeInOutSine
easeInExpo
easeOutExpo
easeInOutExpo
easeInCirc
easeOutCirc
easeInOutCirc
easeInElastic
easeOutElastic
easeInOutElastic
easeInBack
easeOutBack
easeInOutBack
easeInBounce
easeOutBounce
easeInOutBounce
In the following example we have specified in the container for scrolling the #container
.
<div id="container">
<a href="#heading2" data-scroll>Go to Heading2</a>
...
<h2 id="heading2">Heading2</h2>
</div>
const sweetScroll = new SweetScroll({/* some options */}, "#container");
Add the data-scroll-header
attribute in order to offset the height of the fixed header.
<header data-scroll-header></header>
Specify the CSS Selector in header
option instead of the data-scroll-header
attribute.
const sweetScroll = new SweetScroll({
header: "#header"
});
You can override the default options by passing the option in JSON
format to the data-scroll-options
.
<a href="#target" data-scroll data-scroll-options='{"easing": "easeOutBounce"}'>Go to Target</a>
new SweetScroll(options = {}, container = "body, html")
to(distance, options = {})
toTop(distance, options = {})
toLeft(distance, options = {})
destroy()
distance
to can specify the CSS Selector or scroll position.
Example:
const SweetScroll = new SweetScroll();
// CSS Selector of target element
sweetScroll.to("#footer");
// Object
sweetScroll.to({top: 1000, left: 20});
// Array (top:0, left:1000)
sweetScroll.to([0, 1000]);
// Number (Priority to vertical scroll position. by default.)
sweetScroll.to(500);
// String (Like object syntax)
sweetScroll.to("top: 500, left: 100");
// String (Relative position)
sweetScroll.to("+=500")
sweetScroll.to("-=200")
Works in IE9+
, and all modern browsers.
Released under the MIT Licence
Initialization of the project.
$ cd /your/project/dir
$ git clone https://github.com/tsuyoshiwada/sweet-scroll.git
Install some dependencies.
$ npm install
Start the development.
You I can access the http://localhost:3000/
.
$ npm start
Run lint and testing.
$ npm test
Generates build file.
$ npm run build
0.0.1
FAQs
Modern and the sweet smooth scroll library.
The npm package sweet-scroll receives a total of 6,647 weekly downloads. As such, sweet-scroll popularity was classified as popular.
We found that sweet-scroll 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.