-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark.js
1 lines (1 loc) · 897 Bytes
/
bookmark.js
1
window.addEventListener("DOMContentLoaded",()=>{"use strict";var e=()=>{localStorage.setItem("bookmark"+location.pathname,window.scrollY)},o=()=>{var e=localStorage.getItem("bookmark"+location.pathname);e=parseInt(e,10),isNaN(e)||""!==location.hash||window.anime({targets:[document.documentElement,document.body],duration:200,easing:"linear",scrollTop:e})};!function(t){var n=document.querySelector(".book-mark-link");window.addEventListener("scroll",()=>{0===window.scrollY?n.classList.add("book-mark-link-fixed"):n.classList.remove("book-mark-link-fixed")}),"auto"===t&&(window.addEventListener("beforeunload",e),window.addEventListener("pjax:send",e)),n.addEventListener("click",o=>{o.preventDefault(),e(),window.anime({targets:n,duration:200,easing:"linear",top:-30,complete:()=>{setTimeout(()=>{n.style.top=""},400)}})}),o(),window.addEventListener("pjax:success",o)}(CONFIG.bookmark.save)});