File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -233,22 +233,24 @@ Useful if you have anchor links scattered throughout a page, or if you're using
233233```js
234234;(function (window, document, undefined) {
235235
236- 'use strict';
236+ 'use strict';
237237
238- // Cut the mustard
238+ // Cut the mustard
239239 var supports = 'querySelector' in document && 'addEventListener' in window;
240- if ( !supports ) return;
240+ if ( !supports ) return;
241241
242- // Get all anchors
243- var anchors = document.querySelectorAll( '[href*="#"]' );
242+ // Get all anchors
243+ var anchors = document.querySelectorAll( '[href*="#"]' );
244244
245245 // Add smooth scroll to all anchors
246246 for ( var i = 0, len = anchors.length; i < len; i++ ) {
247+ var url = new RegExp( window.location.hostname + window.location.pathname );
248+ if ( !url.test( anchors[i].href ) ) continue;
247249 anchors[i].setAttribute( 'data-scroll', true );
248250 }
249251
250252 // Initial smooth scroll (add your attributes as desired)
251- smoothScroll.init();
253+ smoothScroll.init();
252254
253255})(window, document);
254256```
You can’t perform that action at this time.
0 commit comments