-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookmark.js
More file actions
1 lines (1 loc) · 838 Bytes
/
bookmark.js
File metadata and controls
1 lines (1 loc) · 838 Bytes
1
document.addEventListener("DOMContentLoaded",()=>{"use strict";const 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.scrollingElement,duration:200,easing:"linear",scrollTop:e})};{var t=CONFIG.bookmark.save;const n=document.querySelector(".book-mark-link");window.addEventListener("scroll",()=>n.classList.toggle("book-mark-link-fixed",0===window.scrollY),{passive:!0}),"auto"===t&&(window.addEventListener("beforeunload",e),document.addEventListener("pjax:send",e)),n.addEventListener("click",()=>{e(),window.anime({targets:n,duration:200,easing:"linear",top:-30,complete:()=>{setTimeout(()=>{n.style.top=""},400)}})}),o(),document.addEventListener("pjax:success",o)}});