UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 2.78 kB
/*! For license information please see horizontalScroller.esm.js.LICENSE.txt */ var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,o(i.key),i)}}function o(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}t.d(e,{J:()=>n});var n=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setupa()},e=[{key:"seto",value:function(t){return this.e=t.a,t.speed&&(this.divisor=t.speed),t.height&&(this.setH=t.height),this}},{key:"setupa",value:function(){return this.parallaxIDs(["#rta"]),this.divisor(1),this}},{key:"add",value:function(t){return this.items=t,this.setup(),this}},{key:"parallaxIDs",value:function(t){return this.parallaxIDs=t,this}},{key:"divisor",value:function(t){return this.divisor=t,this}},{key:"setup",value:function(){var t,e=this;this.pts=0;var r=document.createElement("div");r.style.width="100%",r.style.height=null!==(t=this.setH)&&void 0!==t?t:"100%";var i=document.createElement("div");i.style.display="flex",i.style.width="100%";for(var o=0;o<this.items.length;o++){var n=this.items[o].render();i.appendChild(n)}r.appendChild(i);var s=window.localStorage.getItem("pts");null!==s&&(this.pts=s),r.addEventListener("wheel",(function(t){t.deltaY<0?(console.log("Scrolling up"),e.pts--):t.deltaY>0&&(console.log("Scrolling down"),e.pts++),window.localStorage.setItem("pts",e.pts),t.preventDefault();for(var r=0;r<i.childNodes.length;r++){console.log(i.childNodes[r].toString().substr(7));var o=i.childNodes[r];e.parallaxIDs.includes(o.id)&&(o.style.transform="translateX(".concat(e.pts/e.divisor,"%)"))}i.style.transform="translateX(".concat(e.pts/e.divisor,"%)"),window.localStorage.setItem("translation",e.pts/e.divisor)}));var a=window.localStorage.getItem("translation");null!==a&&(i.style.transform="translateX(".concat(a,"%)")),this.div=r}},{key:"render",value:function(t){if(!t)return this.div;document.querySelector(t).appendChild(this.div)}}],e&&i(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),s=e.J;export{s as HScroller};