Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bolt/components-smooth-scroll

Package Overview
Dependencies
Maintainers
4
Versions
351
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bolt/components-smooth-scroll - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

2

package.json

@@ -11,3 +11,3 @@ {

],
"version": "1.1.2",
"version": "1.2.0",
"sourceFilesFrom": "0.9.5",

@@ -14,0 +14,0 @@ "maintainers": [

@@ -5,9 +5,9 @@ import SmoothScroll from 'smooth-scroll';

const defaultScrollOffset = 0;
const defaultScrollSpeed = 500;
const defaultScrollOffset = 45;
const defaultScrollSpeed = 750;
const customScrollElems = document.querySelectorAll('a[href*="#"]');
customScrollElems.forEach(elem => {
const scrollElem = elem;
const scrollSpeed = defaultScrollSpeed;
const customScrollElems = document.querySelectorAll('a[href^="#"]');
for (var i = 0, len = customScrollElems.length; i < len; i++) {
const scrollElem = customScrollElems[i];
const scrollSpeed = defaultScrollSpeed;

@@ -18,29 +18,30 @@ // In the future, we could add support for links to modify options like scrollOffset, scrollOffset, etc. However,

//
const scrollOffset = scrollElem.dataset.scrollOffset ? scrollElem.dataset.scrollOffset : defaultScrollOffset;
const scrollOffset = scrollElem.dataset.scrollOffset ? scrollElem.dataset.scrollOffset : defaultScrollOffset;
// const scrollSpeed = scrollElem.dataset.scrollSpeed ? scrollElem.dataset.scrollSpeed : defaultScrollSpeed;
const scrollOptions = {
ignore: '[data-scroll-ignore]', // Selector for links to ignore (must be a valid CSS selector)
header: '.js-bolt-smooth-scroll-offset', // Selector for fixed headers (must be a valid CSS selector)
const scrollOptions = {
ignore: '[data-scroll-ignore]', // Selector for links to ignore (must be a valid CSS selector)
header: '.js-bolt-smooth-scroll-offset', // Selector for fixed headers (must be a valid CSS selector)
// Speed & Easing
speed: scrollSpeed, // Integer. How fast to complete the scroll in milliseconds
offset: scrollOffset, // Integer or Function returning an integer. How far to offset the scrolling anchor location in pixels
easing: 'easeInOutCubic', // Easing pattern to use
speed: scrollSpeed, // Integer. How fast to complete the scroll in milliseconds
offset: scrollOffset, // Integer or Function returning an integer. How far to offset the scrolling anchor location in pixels
easing: 'easeInOutCubic', // Easing pattern to use
// Callback API
before: function () {}, // Callback to run before scroll
after: function () {}, // Callback to run after scroll
};
// Callback API
before () {}, // Callback to run before scroll
after () {}, // Callback to run after scroll
};
let scrollElemHref = scrollElem.getAttribute('href');
scrollElemHref = scrollElemHref.replace('#', '');
let scrollElemHref = scrollElem.getAttribute('href');
scrollElemHref = scrollElemHref.replace('#', '');
const scrollTarget = document.getElementById(scrollElemHref);
const scrollTarget = document.getElementById(scrollElemHref);
if (scrollTarget) {
scrollElem.addEventListener('click', function(){
scroll.animateScroll(scrollTarget, scrollElem, scrollOptions);
});
}
});
if (scrollTarget) {
scrollElem.addEventListener('click', function(event){
event.preventDefault();
scroll.animateScroll(scrollTarget, scrollElem, scrollOptions);
});
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc