add doc
This commit is contained in:
1 parent
16ef430a39
commit
792897291b
445 files changed
+30584
-5
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
/* global Cookies */
|
||||
|
||||
// Set relative link path (without domain)
|
||||
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, { expires: 365, path: '' });
|
||||
}, 250);
|
||||
});
|
||||
|
||||
// Read position from cookie
|
||||
if (Cookies.get('scroll-cookie') !== undefined) {
|
||||
var cvalues = Cookies.get('scroll-cookie').split('|');
|
||||
if (cvalues[1] === rpath) {
|
||||
$(window).scrollTop(cvalues[0]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user