@localnerve/jump-scroll 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- /*! jump-scroll@0.6.0, Copyright (c) 2023 Alex Grant (@localnerve), LocalNerve LLC, BSD-3-Clause */
2
- class t extends HTMLElement{#t=null;#e=null;#s=null;#r=!0;#i=!1;#o=0;#n="";#a=null;#l=null;#c=null;#h=null;#p=null;#d=null;#u=null;#g=!1;#b=!1;#v=0;static#m=800;static#T=15;static#f=["target"];static#w={target:"section",display:"best"};static get observedAttributes(){return[...t.#f,"display","colormap"]}static getNumber(t){return parseFloat(t.replace(/[^.+\-\d]+/,""))}constructor(){super(),this.attachShadow({mode:"open"}),this.targetIntersection=this.targetIntersection.bind(this),this.controlIntersection=this.controlIntersection.bind(this),this.resizeHandler=this.resizeHandler.bind(this),this.setup=this.setup.bind(this),this.clickTop=this.clickTop.bind(this),this.clickBottom=this.clickBottom.bind(this),this.clickNext=this.clickNext.bind(this),this.clickPrev=this.clickPrev.bind(this),this.createTargetProperties()}createTargetProperties(){t.#f.forEach((e=>{Object.defineProperty(this,e,{get(){return this.hasAttribute(e)?this.getAttribute(e):t.#w[e]},set(t){t?this.setAttribute(e,t):this.removeAttribute(e),this.updateTargetMap(t)}})}))}get display(){const e="display";return this.hasAttribute(e)?this.getAttribute(e):t.#w[e]}set display(t){const e="display",s=["both","best"];this.#u&&this.#u.classList.remove(...s.concat("up","down")),s.includes(t)?(this.setAttribute(e,t),this.#y(),this.#I(),this.#u&&this.#u.classList.add(t)):this.removeAttribute(e)}get colormap(){let t="";const e="colormap";return this.hasAttribute(e)&&(t=this.getAttribute(e)),t}set colormap(t){if(null===this.#u)return;this.#d&&this.#d.clear(),this.#d=null;const e="colormap",s=t&&t.split(";");if(s&&s.length>0&&s[0].includes("@")){this.setAttribute(e,t),this.#d=new Map;for(const t of s){let[e,s]=t.replace(/\s/,"").split("@");s.startsWith("--")&&(s=`var(${s})`),document.querySelectorAll(e).forEach((t=>{this.#d.set(t,s)}))}}else this.removeAttribute(e)}get currentTarget(){return this.#h}set currentTarget(t){this.#p.has(t)&&(this.#h=t,this.#k())}update(t){const e=[t],s=["mid","start","end","rest","up","down"];null!==this.#a&&s.push("none"),"best"===this.display&&"mid"===t&&(this.#r?e.push("down"):e.push("up")),this.#u.classList.remove(...s),this.#u.classList.add(...e),setTimeout((()=>{this.#u.classList.add("rest")}),500)}#S(e,s){const r=this.#p.get(this.#h);if(r[e]){const i=r[e],o=this.#p.get(i),n=Math.round(o.lastTop);this.#h=i,this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"}),this.#k(),setTimeout((()=>{n===Math.round(o.lastTop)&&(s(n)?this.#S(e,s):window.scrollBy({top:n,behavior:"smooth"}))}),16.67*t.#T)}else this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"})}#A(t="start"){this.#h="start"===t?this.#a:this.#l,this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"}),this.#k(),this.update(t)}clickTop(t){t&&t.preventDefault(),this.#A("start")}clickBottom(t){t&&t.preventDefault(),this.#A("end")}clickNext(t){t&&t.preventDefault(),this.#S("next",(t=>t<window.innerHeight))}clickPrev(t){t&&t.preventDefault(),this.#S("prev",(t=>t>0))}#x(){if(!this.#a||!this.#p)return;let t,e;const s={parents:1e6,el:this.#a},r=this.#p.keys();for(const i of r){for(e=i,t=0;e.parentElement;e=e.parentElement)t++;t<s.parents&&(s.parents=t,s.el=i)}return s.el}#j(){if(!this.#a||!this.#p)return;const t=this.#x(),e=t.parentElement??t;if(e){let t;if(e.id)t=e.id;else{const s=new Uint8Array(10);t=`js-${btoa(crypto.getRandomValues(s))}`,e.id=t}if(this.setAttribute("aria-role","scrollbar"),this.setAttribute("aria-controls",t),this.setAttribute("aria-valuemin","0"),this.#p){const t=this.#p.size-1;this.setAttribute("aria-valuemax",t>0?t:1)}}}#k(){this.#p&&this.setAttribute("aria-valuenow",this.#p.get(this.#h).index)}updateTargetMap(e,s){if(!t.#f.includes(e)||!this.#g)return;let r,i;this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#p?this.#p.clear():this.#p=new Map;const o=[];if(document.querySelectorAll(this[e]).forEach((t=>{for(r=t.getBoundingClientRect(),i=0;i<o.length&&!(r.top<o[i].top);i++);(0===i||i>0&&o[i-1].top!==r.top)&&o.splice(i,0,{top:r.top,bot:r.bottom,el:t}),"function"==typeof s&&s(t)})),o.length>0){this.#a=o[0].el,this.#l=o[o.length-1].el,this.#c=new WeakMap([[this.#a,{pos:"start",down:!0}],[this.#l,{pos:"end",down:!1}]]);let t=0,e=0;const s=window.innerHeight;for(i=0;i<o.length;i++)0>o[i].top&&(e=o[i].bot<s?1:0,t=i+e<o.length?i+e:i),this.#p.set(o[i].el,{index:i,prev:i>0?o[i-1].el:null,next:i<o.length-1?o[i+1].el:null});this.#h=o[t].el,this.#k(),0===t?this.update("start"):t===o.length-1?this.update("end"):this.update("mid")}}targetIntersection(t){const e=t=>{const e=this.#p.get(t.target);t.isIntersecting&&t.intersectionRatio>=.95?e.lastTop?e.lastTop<t.boundingClientRect.top&&(e.lastTop=t.boundingClientRect.top):e.lastTop=t.boundingClientRect.top:t.isIntersecting||(e.lastTop=void 0)};let s,r;const i=(t,e,s,r)=>{let i=t;const o=s.target===e&&s||r.target===e&&r;return o&&(i?o.intersectionRatio<i.intersectionRatio&&(i=o):i=o),i},o=.49,n=t.sort(((t,o)=>{const n=t.isIntersecting&&o.isIntersecting;let a=t.isIntersecting?-1:o.isIntersecting?1:0;return s=i(s,this.#a,t,o),r=i(r,this.#l,t,o),e(t),e(o),n&&(a=o.intersectionRatio-t.intersectionRatio),a}))[0];if(n.isIntersecting){const t=this.#p.get(this.#h),e=this.#c.has(n.target),i=this.#p.get(n.target),a=n.boundingClientRect.top,l=n.intersectionRatio,c=n.target,h=e?0:o,{pos:p,down:d}=this.#c.get(c)??{pos:"mid",down:void 0===i.lastTop?this.#r:a<i.lastTop};if(i.lastTop=a,"mid"!==p)this.#i=l>o&&p;else if(this.#i){const t="start"===this.#i?s:r;t&&t.intersectionRatio<=o&&(this.#i=!1)}if(!this.#i||"mid"!==p){(this.#r?i.index>t.index:i.index<t.index)&&l>h&&(this.#h=c,this.#k()),this.update(p),this.#r=d}this.#i&&n.intersectionRatio>=.98&&(this.#h=c,this.#k())}else n.intersectionRatio<=o&&(this.#p.get(n.target).lastTop=void 0)}controlIntersection(t,e){if(this.#d&&!this.#b){const s=e.filter((t=>t.isIntersecting));if(s.length>0){const e=s[0],r=this.#d.get(e.target);this.#o++,this.#n=t,r?this.#u.style.setProperty("--js-bg-color",r):(this.#u.style.removeProperty("--js-bg-color"),this.#o=0)}else{this.#o--;const e=t!==this.#n,s=this.#o<=0&&t===this.#n;(e||s)&&(this.#u.style.removeProperty("--js-bg-color"),this.#o=0)}}}#I(){if(!this.#p)return;const e=window.innerHeight,s=this.offsetHeight,r=e-s,i=Math.abs(s-2),o=t.getNumber(window.getComputedStyle(this).bottom),n=e-o-2;this.#t=new IntersectionObserver(this.targetIntersection,{threshold:[.1,.2,.3,.4,.5,.6,.7,.8,.9,1]}),this.#e=new IntersectionObserver(this.controlIntersection.bind(null,"top"),{threshold:0,rootMargin:`-${r}px 0px -${i}px 0px`}),this.#s=new IntersectionObserver(this.controlIntersection.bind(null,"bot"),{threshold:0,rootMargin:`-${n}px 0px -${o}px 0px`});const a=this.#p.keys();for(const t of a)this.#t.observe(t);const l=this.#d.keys();for(const t of l)this.#e.observe(t),this.#s.observe(t)}#y(){this.#t&&this.#t.disconnect(),this.#e&&this.#e.disconnect(),this.#s&&this.#s.disconnect(),this.#t=null,this.#e=null,this.#s=null}resizeHandler(){this.#b||(this.#b=!0,setTimeout((()=>{let t=!1;const e=window.innerWidth;e!==this.#v&&(e>this.#v&&(t=!0),this.#v=e),this.setup(!1,t),this.#b=!1}),t.#m))}#O(){this.#b=!1,window.addEventListener("resize",this.resizeHandler)}#z(){window.removeEventListener("resize",this.resizeHandler),this.#b=!1}setup(e=!0,s=!0){let r=!1;this.#g?this.teardown(e,s):r=!0,this.#g=!0,s&&t.#f.forEach((t=>{this.updateTargetMap(t)})),r&&(this.#v=window.innerWidth,this.#j()),this.#I(),e&&this.#O()}teardown(t=!0,e=!0){t&&this.#z(),this.#y(),e&&(this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#p&&this.#p.clear(),this.#p=null),this.#g=!1}connectedCallback(){"complete"!==document.readyState?window.addEventListener("load",(()=>{this.setup()}),{once:!0}):this.setup();const{shadowRoot:t}=this;t.innerHTML='<style>:host{--js-width:3rem;--js-aspect-ratio:0.2;--js-height:calc(var(--js-width) * (1 / var(--js-aspect-ratio)));--js-bg-color:black;--js-color:white;--js-opacity-full:0.7;--js-opacity-rest:0.3;--js-attach-right:1rem;--js-attach-bottom:1rem;position:fixed;bottom:var(--js-attach-bottom);right:var(--js-attach-right);color:var(--js-color)}.container{display:block;transition:opacity 1s;opacity:var(--js-opacity-full);width:var(--js-width);height:auto;aspect-ratio:var(--js-aspect-ratio)}.container button{padding:0;margin:0;border:none;color:transparent}.container.best{aspect-ratio:calc(var(--js-aspect-ratio) * 2)}.container.none{display:none}.container.rest{opacity:var(--js-opacity-rest)}.container.mid{transform:none}.container.best.mid.down .top,.container.start .top{pointer-events:none;opacity:0}.container.best.mid.up .bot,.container.end .bot{pointer-events:none;opacity:0;transform:translateY(102%)}.container.best.end .top,.container.best.mid.down .top,.container.best.mid.up .top{transform:translateY(5%)}.container.end .top{transform:translateY(102%)}.bot,.top{position:absolute;width:var(--js-width);height:auto;aspect-ratio:calc(var(--js-aspect-ratio) * 2);transition:opacity 1s,transform 1s;pointer-events:auto}.top{top:0}.bot{bottom:0}.bot .end,.bot .next,.top .prev,.top .start{content:\'\';position:absolute;left:50%;width:100%;background:var(--js-bg-color)}.bot .end,.top .start{height:calc(var(--js-height)/ 6);clip-path:polygon(10% 0%,90% 0%,90% 30%,65% 30%,100% 100%,0% 100%,35% 30%,10% 30%)}.bot .next,.top .prev{height:calc(var(--js-height)/ 4);clip-path:polygon(50% 0%,100% 60%,65% 60%,100% 100%,0% 100%,35% 60%,0% 60%)}.top .prev,.top .start{transform:translateX(-50%)}.bot .end,.bot .next{transform:translateX(-50%) rotateX(180deg)}.top .start{top:0}.top .prev{top:calc((var(--js-height)/ 6) + 10%)}.bot .next{bottom:calc((var(--js-height)/ 6) + 10%)}.bot .end{bottom:0}</style><div class="container none"><div class="top"><button type="button" tabindex="-1" class="start">Scroll to start</button><button type="button" tabindex="-1" class="prev">Scroll to previous</button></div><div class="bot"><button type="button" tabindex="-1" class="next">Scroll to next</button><button type="button" tabindex="-1" class="end">Scroll to end</button></div></div>',this.#u=t.querySelector(".container"),this.display=this.display,this.colormap=this.colormap,t.querySelector(".top .start").addEventListener("click",this.clickTop),t.querySelector(".bot .end").addEventListener("click",this.clickBottom),t.querySelector(".top .prev").addEventListener("click",this.clickPrev),t.querySelector(".bot .next").addEventListener("click",this.clickNext)}disconnectedCallback(){this.#u=null,this.shadowRoot.querySelector(".top .start").removeEventListener("click",this.clickTop),this.shadowRoot.querySelector(".bot .end").removeEventListener("click",this.clickBottom),this.shadowRoot.querySelector(".top. .prev").removeEventListener("click",this.clickPrev),this.shadowRoot.querySelector(".bot .next").removeEventListener("click",this.clickNext),this.teardown()}attributeChangedCallback(t,e,s){s!==e&&(this[t]=this.getAttribute(t))}}customElements.define("jump-scroll",t);
1
+ /*! jump-scroll@0.6.1, Copyright (c) 2023 Alex Grant (@localnerve), LocalNerve LLC, BSD-3-Clause */
2
+ class t extends HTMLElement{#t=null;#e=null;#s=null;#r=!0;#i=!1;#o=0;#n="";#a=null;#l=null;#c=null;#h=null;#p=null;#d=null;#u=null;#g=!1;#b=!1;#m=0;static#v=800;static#T=15;static#f=["target"];static#w={target:"section",display:"best"};static get observedAttributes(){return[...t.#f,"display","colormap"]}static getNumber(t){return parseFloat(t.replace(/[^.+\-\d]+/,""))}constructor(){super(),this.attachShadow({mode:"open"}),this.targetIntersection=this.targetIntersection.bind(this),this.controlIntersection=this.controlIntersection.bind(this),this.resizeHandler=this.resizeHandler.bind(this),this.setup=this.setup.bind(this),this.clickTop=this.clickTop.bind(this),this.clickBottom=this.clickBottom.bind(this),this.clickNext=this.clickNext.bind(this),this.clickPrev=this.clickPrev.bind(this),this.createTargetProperties()}createTargetProperties(){t.#f.forEach((e=>{Object.defineProperty(this,e,{get(){return this.hasAttribute(e)?this.getAttribute(e):t.#w[e]},set(t){t?this.setAttribute(e,t):this.removeAttribute(e),this.updateTargetMap(t)}})}))}get display(){const e="display";return this.hasAttribute(e)?this.getAttribute(e):t.#w[e]}set display(t){const e="display",s=["both","best"];this.#u&&this.#u.classList.remove(...s.concat("up","down")),s.includes(t)?(this.setAttribute(e,t),this.#y(),this.#I(),this.#u&&this.#u.classList.add(t)):this.removeAttribute(e)}get colormap(){let t="";const e="colormap";return this.hasAttribute(e)&&(t=this.getAttribute(e)),t}set colormap(t){if(null===this.#u)return;this.#d&&this.#d.clear(),this.#d=null;const e="colormap",s=t&&t.split(";");if(s&&s.length>0&&s[0].includes("@")){this.setAttribute(e,t),this.#d=new Map;for(const t of s){let[e,s]=t.replace(/\s/,"").split("@");s.startsWith("--")&&(s=`var(${s})`),document.querySelectorAll(e).forEach((t=>{this.#d.set(t,s)}))}}else this.removeAttribute(e)}get currentTarget(){return this.#h}set currentTarget(t){this.#p.has(t)&&(this.#h=t,this.#k())}update(t){const e=[t],s=["mid","start","end","rest","up","down"];null!==this.#a&&s.push("none"),"best"===this.display&&"mid"===t&&(this.#r?e.push("down"):e.push("up")),this.#u.classList.remove(...s),this.#u.classList.add(...e),setTimeout((()=>{this.#u.classList.add("rest")}),500)}#A(e,s){const r=this.#p.get(this.#h);if(r[e]){const i=r[e],o=this.#p.get(i),n=Math.round(o.lastTop);this.#h=i,this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"}),this.#k(),setTimeout((()=>{n===Math.round(o.lastTop)&&(s(n)?this.#A(e,s):window.scrollBy({top:n,behavior:"smooth"}))}),16.67*t.#T)}else this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"})}#S(t="start"){this.#h="start"===t?this.#a:this.#l,this.#h.scrollIntoView({block:"nearest",inline:"start",behavior:"smooth"}),this.#k(),this.update(t)}clickTop(t){t&&t.preventDefault(),this.#S("start")}clickBottom(t){t&&t.preventDefault(),this.#S("end")}clickNext(t){t&&t.preventDefault(),this.#A("next",(t=>t<window.innerHeight))}clickPrev(t){t&&t.preventDefault(),this.#A("prev",(t=>t>0))}#x(){if(!this.#a||!this.#p)return;let t,e,s=1e6;const r=[],i=this.#p.keys();for(const o of i){for(e=o,t=0;e.parentElement;e=e.parentElement)t++;t<=s&&(s=t,r.unshift(o))}let o=r[0].parentElement??r[0];if(r.length>1){const t=new Range;t.setStart(r[0],0),t.setEnd(r[1],0),t.collapsed&&(t.setStart(r[1],0),t.setEnd(r[0],0)),o=t.commonAncestorContainer??o}return o}#j(){if(!this.#a||!this.#p)return;const t=this.#x();if(t){let e;if(t.id)e=t.id;else{const s=new Uint8Array(10);e=`js-${btoa(crypto.getRandomValues(s))}`,t.id=e}if(this.setAttribute("aria-role","scrollbar"),this.setAttribute("aria-controls",e),this.setAttribute("aria-valuemin","0"),this.#p){const t=this.#p.size-1;this.setAttribute("aria-valuemax",t>0?t:1)}}}#k(){this.#p&&this.setAttribute("aria-valuenow",this.#p.get(this.#h).index)}updateTargetMap(e,s){if(!t.#f.includes(e)||!this.#g)return;let r,i;this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#p?this.#p.clear():this.#p=new Map;const o=[];if(document.querySelectorAll(this[e]).forEach((t=>{for(r=t.getBoundingClientRect(),i=0;i<o.length&&!(r.top<o[i].top);i++);(0===i||i>0&&o[i-1].top!==r.top)&&o.splice(i,0,{top:r.top,bot:r.bottom,el:t}),"function"==typeof s&&s(t)})),o.length>0){this.#a=o[0].el,this.#l=o[o.length-1].el,this.#c=new WeakMap([[this.#a,{pos:"start",down:!0}],[this.#l,{pos:"end",down:!1}]]);let t=0,e=0;const s=window.innerHeight;for(i=0;i<o.length;i++)0>o[i].top&&(e=o[i].bot<s?1:0,t=i+e<o.length?i+e:i),this.#p.set(o[i].el,{index:i,prev:i>0?o[i-1].el:null,next:i<o.length-1?o[i+1].el:null});this.#h=o[t].el,this.#k(),0===t?this.update("start"):t===o.length-1?this.update("end"):this.update("mid")}}targetIntersection(t){const e=t=>{const e=this.#p.get(t.target);t.isIntersecting&&t.intersectionRatio>=.95?e.lastTop?e.lastTop<t.boundingClientRect.top&&(e.lastTop=t.boundingClientRect.top):e.lastTop=t.boundingClientRect.top:t.isIntersecting||(e.lastTop=void 0)};let s,r;const i=(t,e,s,r)=>{let i=t;const o=s.target===e&&s||r.target===e&&r;return o&&(i?o.intersectionRatio<i.intersectionRatio&&(i=o):i=o),i},o=.49,n=t.sort(((t,o)=>{const n=t.isIntersecting&&o.isIntersecting;let a=t.isIntersecting?-1:o.isIntersecting?1:0;return s=i(s,this.#a,t,o),r=i(r,this.#l,t,o),e(t),e(o),n&&(a=o.intersectionRatio-t.intersectionRatio),a}))[0];if(n.isIntersecting){const t=this.#p.get(this.#h),e=this.#c.has(n.target),i=this.#p.get(n.target),a=n.boundingClientRect.top,l=n.intersectionRatio,c=n.target,h=e?0:o,{pos:p,down:d}=this.#c.get(c)??{pos:"mid",down:void 0===i.lastTop?this.#r:a<i.lastTop};if(i.lastTop=a,"mid"!==p)this.#i=l>o&&p;else if(this.#i){const t="start"===this.#i?s:r;t&&t.intersectionRatio<=o&&(this.#i=!1)}if(!this.#i||"mid"!==p){(this.#r?i.index>t.index:i.index<t.index)&&l>h&&(this.#h=c,this.#k()),this.update(p),this.#r=d}this.#i&&n.intersectionRatio>=.98&&(this.#h=c,this.#k())}else n.intersectionRatio<=o&&(this.#p.get(n.target).lastTop=void 0)}controlIntersection(t,e){if(this.#d&&!this.#b){const s=e.filter((t=>t.isIntersecting));if(s.length>0){const e=s[0],r=this.#d.get(e.target);this.#o++,this.#n=t,r?this.#u.style.setProperty("--js-bg-color",r):(this.#u.style.removeProperty("--js-bg-color"),this.#o=0)}else{this.#o--;const e=t!==this.#n,s=this.#o<=0&&t===this.#n;(e||s)&&(this.#u.style.removeProperty("--js-bg-color"),this.#o=0)}}}#I(){if(!this.#p)return;const e=window.innerHeight,s=this.offsetHeight,r=e-s,i=Math.abs(s-2),o=t.getNumber(window.getComputedStyle(this).bottom),n=e-o-2;this.#t=new IntersectionObserver(this.targetIntersection,{threshold:[.1,.2,.3,.4,.5,.6,.7,.8,.9,1]}),this.#e=new IntersectionObserver(this.controlIntersection.bind(null,"top"),{threshold:0,rootMargin:`-${r}px 0px -${i}px 0px`}),this.#s=new IntersectionObserver(this.controlIntersection.bind(null,"bot"),{threshold:0,rootMargin:`-${n}px 0px -${o}px 0px`});const a=this.#p.keys();for(const t of a)this.#t.observe(t);const l=this.#d.keys();for(const t of l)this.#e.observe(t),this.#s.observe(t)}#y(){this.#t&&this.#t.disconnect(),this.#e&&this.#e.disconnect(),this.#s&&this.#s.disconnect(),this.#t=null,this.#e=null,this.#s=null}resizeHandler(){this.#b||(this.#b=!0,setTimeout((()=>{let t=!1;const e=window.innerWidth;e!==this.#m&&(e>this.#m&&(t=!0),this.#m=e),this.setup(!1,t),this.#b=!1}),t.#v))}#O(){this.#b=!1,window.addEventListener("resize",this.resizeHandler)}#C(){window.removeEventListener("resize",this.resizeHandler),this.#b=!1}setup(e=!0,s=!0){let r=!1;this.#g?this.teardown(e,s):r=!0,this.#g=!0,s&&t.#f.forEach((t=>{this.updateTargetMap(t)})),r&&(this.#m=window.innerWidth,this.#j()),this.#I(),e&&this.#O()}teardown(t=!0,e=!0){t&&this.#C(),this.#y(),e&&(this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#p&&this.#p.clear(),this.#p=null),this.#g=!1}connectedCallback(){"complete"!==document.readyState?window.addEventListener("load",(()=>{this.setup()}),{once:!0}):this.setup();const{shadowRoot:t}=this;t.innerHTML='<style>:host{--js-width:3rem;--js-aspect-ratio:0.2;--js-height:calc(var(--js-width) * (1 / var(--js-aspect-ratio)));--js-bg-color:black;--js-color:white;--js-opacity-full:0.7;--js-opacity-rest:0.3;--js-attach-right:1rem;--js-attach-bottom:1rem;position:fixed;bottom:var(--js-attach-bottom);right:var(--js-attach-right);color:var(--js-color)}.container{display:block;transition:opacity 1s;opacity:var(--js-opacity-full);width:var(--js-width);height:auto;aspect-ratio:var(--js-aspect-ratio)}.container button{padding:0;margin:0;border:none;color:transparent}.container.best{aspect-ratio:calc(var(--js-aspect-ratio) * 2)}.container.none{display:none}.container.rest{opacity:var(--js-opacity-rest)}.container.mid{transform:none}.container.best.mid.down .top,.container.start .top{pointer-events:none;opacity:0}.container.best.mid.up .bot,.container.end .bot{pointer-events:none;opacity:0;transform:translateY(102%)}.container.best.end .top,.container.best.mid.down .top,.container.best.mid.up .top{transform:translateY(5%)}.container.end .top{transform:translateY(102%)}.bot,.top{position:absolute;width:var(--js-width);height:auto;aspect-ratio:calc(var(--js-aspect-ratio) * 2);transition:opacity 1s,transform 1s;pointer-events:auto}.top{top:0}.bot{bottom:0}.bot .end,.bot .next,.top .prev,.top .start{content:\'\';position:absolute;left:50%;width:100%;background:var(--js-bg-color)}.bot .end,.top .start{height:calc(var(--js-height)/ 6);clip-path:polygon(10% 0%,90% 0%,90% 30%,65% 30%,100% 100%,0% 100%,35% 30%,10% 30%)}.bot .next,.top .prev{height:calc(var(--js-height)/ 4);clip-path:polygon(50% 0%,100% 60%,65% 60%,100% 100%,0% 100%,35% 60%,0% 60%)}.top .prev,.top .start{transform:translateX(-50%)}.bot .end,.bot .next{transform:translateX(-50%) rotateX(180deg)}.top .start{top:0}.top .prev{top:calc((var(--js-height)/ 6) + 10%)}.bot .next{bottom:calc((var(--js-height)/ 6) + 10%)}.bot .end{bottom:0}</style><div class="container none"><div class="top"><button type="button" tabindex="-1" class="start">Scroll to start</button><button type="button" tabindex="-1" class="prev">Scroll to previous</button></div><div class="bot"><button type="button" tabindex="-1" class="next">Scroll to next</button><button type="button" tabindex="-1" class="end">Scroll to end</button></div></div>',this.#u=t.querySelector(".container"),this.display=this.display,this.colormap=this.colormap,t.querySelector(".top .start").addEventListener("click",this.clickTop),t.querySelector(".bot .end").addEventListener("click",this.clickBottom),t.querySelector(".top .prev").addEventListener("click",this.clickPrev),t.querySelector(".bot .next").addEventListener("click",this.clickNext)}disconnectedCallback(){this.#u=null,this.shadowRoot.querySelector(".top .start").removeEventListener("click",this.clickTop),this.shadowRoot.querySelector(".bot .end").removeEventListener("click",this.clickBottom),this.shadowRoot.querySelector(".top. .prev").removeEventListener("click",this.clickPrev),this.shadowRoot.querySelector(".bot .next").removeEventListener("click",this.clickNext),this.teardown()}attributeChangedCallback(t,e,s){s!==e&&(this[t]=this.getAttribute(t))}}customElements.define("jump-scroll",t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localnerve/jump-scroll",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A small, fast, no-dep, jump-scroll web component",
5
5
  "main": "dist/index.js",
6
6
  "browser": "dist/jump-scroll.js",