vanilla-back-to-top
Advanced tools
Comparing version 1.0.6 to 1.1.0
@@ -1,1 +0,1 @@ | ||
function addBackToTop({id:e="back-to-top",scrollContainer:t=document.documentElement,showWhenScrollTopIs:n=300,innerElement:o=document.createTextNode("Up"),size:c=50,fontSize:d=14,cornerOffset:i=20,backgroundColor:r="#000",textColor:a="#fff",zIndex:l=1}){!function(){const t=`#${e}{bottom:${i}px;opacity:1;position:fixed;right:${i}px;transition:bottom 0.2s, opacity 0.2s;z-index:${l};}#${e}.hidden{bottom:-${c}px;opacity:0;}#${e} a{align-items:center;background:${r};border-radius:${c}px;color:${a};display:flex;font-size:${d}px;height:${c}px;justify-content:center;text-decoration:none;width:${c}px;}`,n=document.createElement("style");n.appendChild(document.createTextNode(t)),document.head.insertAdjacentElement("afterbegin",n)}();const s=function(){const t=document.createElement("div");t.id=e;const n=document.createElement("a");return n.setAttribute("href","#"),n.appendChild(o),t.appendChild(n),document.body.appendChild(t),t}();let p;m(),(t===document.documentElement?window:t).onscroll=(()=>{t.scrollTop>=n?function(){if(!p)return;s.className="",p=!1}():m()});function m(){p||(s.className="hidden",p=!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:a="#000",textColor:l="#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:${a};border-radius:${d}px;color:${l};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(()=>{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.0.6", | ||
"version": "1.1.0", | ||
"description": "Configurable zero dependency Back To Top button", | ||
@@ -21,4 +21,4 @@ "main": "dist/index.js", | ||
"precommit": "npm run build && git add ./dist/index.js", | ||
"postversion": "node postversion", | ||
"build": "node build", | ||
"postversion": "node scripts/postversion", | ||
"build": "node scripts/build", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -25,0 +25,0 @@ }, |
@@ -13,3 +13,3 @@ # Vanilla Back To Top | ||
``` | ||
<script src="https://unpkg.com/vanilla-back-to-top@@1.0.6/dist/index.js"></script> | ||
<script src="https://unpkg.com/vanilla-back-to-top@@1.1.0/dist/index.js"></script> | ||
<script>addBackToTop({})</script> | ||
@@ -39,2 +39,3 @@ ``` | ||
showWhenScrollTopIs: 300, | ||
onClickScrollTo: 0, | ||
innerElement: document.createTextNode('Up'), | ||
@@ -54,2 +55,3 @@ size: 50, | ||
- `showWhenScrollTopIs` - show the button when page got scrolled by this number of pixels | ||
- `onClickScrollTo` - where to scroll to when the button gets clicked, `0` means the very top | ||
- `innerElement` - DOM element to put inside the button; with jQuery you can put something like this: `$('<svg>...</svg>').get(0)` | ||
@@ -56,0 +58,0 @@ - `size` - width and height of the button in pixels |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
62
0
3807
3
0