Skip to content

Commit e39e069

Browse files
authored
v10.2.1 (cferdinandi#307)
Added support for Chinese, Cyrillic, and other non-ASCII characters
1 parent 4547e8e commit e39e069

File tree

8 files changed

+78
-13
lines changed

8 files changed

+78
-13
lines changed

dist/js/smooth-scroll.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v10.2.0: Animate scrolling to anchor links
2+
* smooth-scroll v10.2.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -413,7 +413,13 @@
413413
var hashChangeHandler = function (event) {
414414

415415
// Get hash from URL
416-
var hash = root.location.hash;
416+
// var hash = decodeURIComponent( escapeCharacters( root.location.hash ) );
417+
var hash;
418+
try {
419+
hash = escapeCharacters( decodeURIComponent( root.location.hash ) );
420+
} catch(e) {
421+
hash = escapeCharacters( root.location.hash );
422+
}
417423

418424
// Only run if there's an anchor element to scroll to
419425
if ( !anchor ) return;
@@ -447,7 +453,14 @@
447453
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;
448454

449455
// Get the sanitized hash
450-
var hash = escapeCharacters( toggle.hash );
456+
// var hash = decodeURIComponent( escapeCharacters( toggle.hash ) );
457+
// console.log(hash);
458+
var hash;
459+
try {
460+
hash = escapeCharacters( decodeURIComponent( toggle.hash ) );
461+
} catch(e) {
462+
hash = escapeCharacters( toggle.hash );
463+
}
451464

452465
// If the hash is empty, scroll to the top of the page
453466
if ( hash === '#' ) {

dist/js/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/smooth-scroll.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v10.2.0: Animate scrolling to anchor links
2+
* smooth-scroll v10.2.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -413,7 +413,13 @@
413413
var hashChangeHandler = function (event) {
414414

415415
// Get hash from URL
416-
var hash = root.location.hash;
416+
// var hash = decodeURIComponent( escapeCharacters( root.location.hash ) );
417+
var hash;
418+
try {
419+
hash = escapeCharacters( decodeURIComponent( root.location.hash ) );
420+
} catch(e) {
421+
hash = escapeCharacters( root.location.hash );
422+
}
417423

418424
// Only run if there's an anchor element to scroll to
419425
if ( !anchor ) return;
@@ -447,7 +453,14 @@
447453
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;
448454

449455
// Get the sanitized hash
450-
var hash = escapeCharacters( toggle.hash );
456+
// var hash = decodeURIComponent( escapeCharacters( toggle.hash ) );
457+
// console.log(hash);
458+
var hash;
459+
try {
460+
hash = escapeCharacters( decodeURIComponent( toggle.hash ) );
461+
} catch(e) {
462+
hash = escapeCharacters( toggle.hash );
463+
}
451464

452465
// If the hash is empty, scroll to the top of the page
453466
if ( hash === '#' ) {

0 commit comments

Comments
 (0)