Vanilla JS Smooth Scroll
Easy to use!
Usage:
            
var smoothScroll = new scrollToSmooth('a', {
  targetAttribute: 'href',
  duration: 800,
  easing: 'easeOutCubic',
  callback: function () { console.log('we reached it!'); },
  fixedHeader: null
})
smoothScroll.init();
      
      

Options:

speed
Type: Number
Default: 400

Scroll time in milliseconds

easing
Type: string
Default: linear

Easing function used for scrolling.
Available Easings:

  • linear
  • easeInQuad
  • easeOutQuad
  • easeInOutQuad
  • easeInCubic
  • easeOutCubic
  • easeInOutCubic
  • easeInQuart
  • easeOutQuart
  • easeInOutQuart
  • easeInQuint
  • easeOutQuint
  • easeInOutQuint
  • easeInElastic
  • easeOutElastic
  • easeInOutElastic

callback
Type: function
Default: null

Callback to be executed when scrolling is finished

fixedHeader
Type: string
Default: null

The header element
Example: '#fixed-header'

Here we go!