@vtbag/turn-signal
Version:
Turn-Signal is a lightweight script that enhances cross-document navigation by detecting the direction of browser navigation. It enables developers to create smooth, responsive transitions that adjust based on forward or backward navigation, delivering a
2 lines (1 loc) • 450 B
JavaScript
;(()=>{var t=window.navigation;function a(e){if(e.navigationType==="push"){let i=t?.entries()??[],r=e.destination.url;for(let n=t?.currentEntry?.index??-1;n>=0;--n)if(r===i[n].url){e.preventDefault(),history.go(n-window.navigation?.currentEntry.index);return}for(let n=t?.currentEntry?.index??i.length;n<i.length;++n)if(r===i[n].url){e.preventDefault(),history.go(n-t?.currentEntry.index);return}}}t?.addEventListener("navigate",a);})();