Skip to content

Commit 1e4f8dc

Browse files
committed
Fix bug: when pageYOffset is not zero,the first time animate scrolling will got an error.
1 parent 2e3e743 commit 1e4f8dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/js/smooth-scroll/smooth-scroll.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273

274274
// Get the hash to use
275275
var hash = window.location.hash;
276-
hash = hash ? hash : window.pageYOffset;
276+
hash = hash ? hash : '';
277277

278278
// Set a default history
279279
history.replaceState(
@@ -542,7 +542,7 @@
542542

543543
// Get the anchor
544544
var anchor = history.state.anchor;
545-
if (anchor && anchor !== 0) {
545+
if (typeof anchor === 'string' && anchor) {
546546
anchor = document.querySelector(escapeCharacters(history.state.anchor));
547547
if (!anchor) return;
548548
}

0 commit comments

Comments
 (0)