vanilla-back-to-top
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,1 +0,1 @@ | ||
function addBackToTop({id:e="back-to-top",scrollContainer:t=document.documentElement,showWhenScrollTopIs:n=300,onClickScrollTo:o=0,innerElement:c=document.createTextNode("Up"),size:d=50,fontSize:i=14,cornerOffset:r=20,backgroundColor:l="#000",textColor:a="#fff",zIndex:s=1}){!function(){const t=`#${e}{bottom:${r}px;opacity:1;position:fixed;right:${r}px;transition:bottom 0.2s, opacity 0.2s;z-index:${s};}#${e}.hidden{bottom:-${d}px;opacity:0;}#${e} a{align-items:center;background:${l};border-radius:${d}px;color:${a};display:flex;font-size:${i}px;height:${d}px;justify-content:center;text-decoration:none;width:${d}px;}`,n=document.createElement("style");n.appendChild(document.createTextNode(t)),document.head.insertAdjacentElement("afterbegin",n)}();const p=function(){const n=document.createElement("div");n.id=e;const d=document.createElement("a");return d.addEventListener("click",e=>{e.preventDefault(),t.scrollTop=o}),d.appendChild(c),n.appendChild(d),document.body.appendChild(n),n}();let m;u(),(t===document.documentElement?window:t).addEventListener("scroll",()=>{t.scrollTop>=n?function(){if(!m)return;p.className="",m=!1}():u()});function u(){m||(p.className="hidden",m=!0)}} | ||
function addBackToTop({id:e="back-to-top",scrollContainer:t=document.documentElement,showWhenScrollTopIs:n=300,onClickScrollTo:o=0,innerElement:c=document.createTextNode("Up"),size:d=50,fontSize:i=14,cornerOffset:r=20,backgroundColor:l="#000",textColor:a="#fff",zIndex:s=1}){!function(){const t=`#${e}{bottom:${r}px;opacity:1;position:fixed;right:${r}px;transition:bottom 0.2s, opacity 0.2s;z-index:${s};}#${e}.hidden{bottom:-${d}px;opacity:0;}#${e} a{align-items:center;background:${l};border-radius:${d}px;color:${a};cursor:pointer;display:flex;font-size:${i}px;height:${d}px;justify-content:center;text-decoration:none;width:${d}px;}`,n=document.createElement("style");n.appendChild(document.createTextNode(t)),document.head.insertAdjacentElement("afterbegin",n)}();const p=function(){const n=document.createElement("div");n.id=e;const d=document.createElement("a");return d.addEventListener("click",e=>{e.preventDefault(),t.scrollTop=o}),d.appendChild(c),n.appendChild(d),document.body.appendChild(n),n}();let m;u(),(t===document.documentElement?window:t).addEventListener("scroll",()=>{t.scrollTop>=n?function(){if(!m)return;p.className="",m=!1}():u()});function u(){m||(p.className="hidden",m=!0)}} |
{ | ||
"name": "vanilla-back-to-top", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Configurable zero dependency Back To Top button", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,3 +13,3 @@ # Vanilla Back To Top | ||
``` | ||
<script src="https://unpkg.com/vanilla-back-to-top@1.1.2/dist/index.js"></script> | ||
<script src="https://unpkg.com/vanilla-back-to-top@1.1.3/dist/index.js"></script> | ||
<script>addBackToTop({})</script> | ||
@@ -16,0 +16,0 @@ ``` |
3830