1.1.2 • Published 5 years ago

@slicemenice/jquery-smooth-anchor-scroll v1.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

jQuery Smooth Anchor Scroll

Usage

Include jquery-smooth-anchor-scroll.js to add support for smooth anchor scrolling to your website.

Optionally: Configure the scrolling duration either globally or per link element.

// Include this before including jquery-smooth-anchor-scroll.js

( function() {

	$( document ).ready( function() {

		window.smoothAnchorScroll = window.smoothAnchorScroll || {};

		window.smoothAnchorScroll = {
			// 600ms is the default scrolling duration
			// this can also be a function returning a duration in milliseconds
			duration: 600
		};

	} );

} )();
// Scrolling duration per link element

<a href="#some-anchor" data-smooth-anchor-scroll-duration="200">Smooth scroll to anchor</a>

Optionally: Configure the scrolling offset

// Include this before including jquery-smooth-anchor-scroll.js

( function() {

	$( document ).ready( function() {

		window.smoothAnchorScroll = window.smoothAnchorScroll || {};

		window.smoothAnchorScroll = {
			// this can also be a function returning the offset in pixels
			offset: 80
		};

	} );

} )();

Release History

1.1.3

  • Replaced setting the url hash using history.replaceState if available.

1.1.2

  • Fixed reference to window object.

1.1.1

  • Exclude certain hash types.

1.1.0

  • Added beforeScroll and afterScroll hooks.

1.0.0

  • Initial version.