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

gatsby-plugin-smoothscroll

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-smoothscroll

Polyfilled smooth scrolling behavior and helper function for Gatsby sites.

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.4K
increased by19.11%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-plugin-smoothscroll

Polyfilled smooth scrolling behavior and helper function for Gatsby sites.

The plugin uses smoothscroll-polyfill and calls it during the onClientEntry Gatsby lifecycle method.

It also includes a scrollTo helper function as its main export that you can use as onClick event handlers to scroll to the desired element using { behavior: 'smooth' }.

How to install

# npm
npm install gatsby-plugin-smoothscroll

# yarn
yarn add gatsby-plugin-smoothscroll

When do I use this plugin?

When you want a polyfilled smooth scroll behavior without having to manually install and call the polyfill.

Examples of usage

Just add the plugin to the plugins array in your gatsby-config.js:

plugins: [`gatsby-plugin-smoothscroll`];

If you want to use the helper function, import it:

// this could be in your `pages/index.js` file

import scrollTo from 'gatsby-plugin-smoothscroll';

Then use it as an onClick event handler:

<button onClick={() => scrollTo('#some-id')}>My link</button>

Be aware that scrollTo uses document.querySelector() under the hood, so make sure to respect its syntax.

Keywords

FAQs

Package last updated on 21 Jul 2020

Did you know?

Socket

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.

Install

Related posts

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