Skip to content

Commit

Permalink
FIX: save_scroll main script file. [4]
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-nginx authored Apr 8, 2017
1 parent 579a788 commit 0070675
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions source/js/src/scroll-cookie.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
$(document).ready(function() {

// Set relative link path (without domain)
// https://stackoverflow.com/questions/3955959/whats-an-easy-way-to-get-the-url-in-the-current-window-minus-the-domain-name
var rpath = window.location.href.replace(window.location.origin, "");

// Write position in cookie
var timeout;
$(window).on("scroll", function() {
clearTimeout(timeout);
timeout = setTimeout(function () {
Cookies.set("scroll-cookie", ($(window).scrollTop() + "|" + rpath), { path: '' });
Cookies.set("scroll-cookie", ($(window).scrollTop() + "|" + rpath), { expires: 365, path: '' });
}, 250);
});

Expand Down

0 comments on commit 0070675

Please sign in to comment.