Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Update URL before animation #27

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions smooth-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// Function to update URL
var updateURL = function (url, anchor) {
if ( url === 'true' && history.pushState ) {
window.location.hash = '#' + anchor.id;
history.pushState(null, null, '#' + anchor.id);
}
};

Expand Down Expand Up @@ -84,7 +84,6 @@
var currentLocation = window.pageYOffset;
if ( currentLocation == endLocation || ( (window.innerHeight + currentLocation) >= document.body.scrollHeight ) ) {
clearInterval(runAnimation);
updateURL(url, anchor);
}
};

Expand All @@ -101,6 +100,9 @@
window.scrollTo( 0, position );
stopAnimation();
};

//Update URL before animation
updateURL(url, anchor);

// Loop the animation function
var runAnimation = setInterval(animateScroll, 16);
Expand Down Expand Up @@ -135,4 +137,4 @@

}

})();
})();