Skip to content

Commit

Permalink
v11.1.0
Browse files Browse the repository at this point in the history
Added option to ignore links with a specific selector (useful if using the a[href*="#"] selector option)
  • Loading branch information
cferdinandi committed May 18, 2017
1 parent 88b37f5 commit 8a210c6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 47 deletions.
8 changes: 3 additions & 5 deletions dist/js/smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* smooth-scroll v11.0.2: Animate scrolling to anchor links
* smooth-scroll v11.1.0: Animate scrolling to anchor links
* (c) 2017 Chris Ferdinandi
* GPL-3.0 License
* http://github.com/cferdinandi/smooth-scroll
Expand Down Expand Up @@ -29,6 +29,7 @@
var defaults = {
// Selectors
selector: '[data-scroll]',
ignore: '[data-scroll-ignore]',
selectorHeader: null,

// Speed & Easing
Expand Down Expand Up @@ -431,7 +432,6 @@
var hashChangeHandler = function (event) {

// Get hash from URL
// var hash = decodeURIComponent( escapeCharacters( root.location.hash ) );
var hash;
try {
hash = escapeCharacters( decodeURIComponent( root.location.hash ) );
Expand Down Expand Up @@ -465,14 +465,12 @@

// Check if a smooth scroll link was clicked
toggle = getClosest( event.target, settings.selector );
if ( !toggle || toggle.tagName.toLowerCase() !== 'a' ) return;
if ( !toggle || toggle.tagName.toLowerCase() !== 'a' || getClosest( event.target, settings.ignore ) ) return;

// Only run if link is an anchor and points to the current page
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;

// Get the sanitized hash
// var hash = decodeURIComponent( escapeCharacters( toggle.hash ) );
// console.log(hash);
var hash;
try {
hash = escapeCharacters( decodeURIComponent( toggle.hash ) );
Expand Down
4 changes: 2 additions & 2 deletions dist/js/smooth-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions docs/dist/js/smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* smooth-scroll v11.0.2: Animate scrolling to anchor links
* smooth-scroll v11.1.0: Animate scrolling to anchor links
* (c) 2017 Chris Ferdinandi
* GPL-3.0 License
* http://github.com/cferdinandi/smooth-scroll
Expand Down Expand Up @@ -29,6 +29,7 @@
var defaults = {
// Selectors
selector: '[data-scroll]',
ignore: '[data-scroll-ignore]',
selectorHeader: null,

// Speed & Easing
Expand Down Expand Up @@ -431,7 +432,6 @@
var hashChangeHandler = function (event) {

// Get hash from URL
// var hash = decodeURIComponent( escapeCharacters( root.location.hash ) );
var hash;
try {
hash = escapeCharacters( decodeURIComponent( root.location.hash ) );
Expand Down Expand Up @@ -465,14 +465,12 @@

// Check if a smooth scroll link was clicked
toggle = getClosest( event.target, settings.selector );
if ( !toggle || toggle.tagName.toLowerCase() !== 'a' ) return;
if ( !toggle || toggle.tagName.toLowerCase() !== 'a' || getClosest( event.target, settings.ignore ) ) return;

// Only run if link is an anchor and points to the current page
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;

// Get the sanitized hash
// var hash = decodeURIComponent( escapeCharacters( toggle.hash ) );
// console.log(hash);
var hash;
try {
hash = escapeCharacters( decodeURIComponent( toggle.hash ) );
Expand Down
Loading

0 comments on commit 8a210c6

Please sign in to comment.