Comparing version 4.0.9 to 4.1.0
@@ -1,10 +0,10 @@ | ||
import type { UkiyoOptions, TElement } from '../types/index.ts'; | ||
import type { UkiyoOptions, TElement } from './types.ts'; | ||
export default class Ukiyo { | ||
private elements; | ||
private options?; | ||
readonly elements: HTMLElement[]; | ||
readonly options?: UkiyoOptions; | ||
private instances; | ||
private externalRAF; | ||
readonly externalRAF: boolean; | ||
private requestId?; | ||
private timer?; | ||
private onResizeEvent; | ||
readonly onResizeEvent: EventListenerOrEventListenerObject; | ||
private isInit; | ||
@@ -11,0 +11,0 @@ constructor(elements: TElement | null, options?: UkiyoOptions); |
@@ -1,2 +0,2 @@ | ||
import type { UkiyoOptions } from '../types/index.ts'; | ||
import type { UkiyoOptions } from './types.ts'; | ||
/** | ||
@@ -6,3 +6,3 @@ * Parallax class | ||
export declare class Parallax { | ||
private options; | ||
readonly options: UkiyoOptions; | ||
private element; | ||
@@ -23,3 +23,3 @@ private wrapper; | ||
/** | ||
* Update options | ||
* Update options based on element attributes | ||
*/ | ||
@@ -32,24 +32,14 @@ private updateOptions; | ||
/** | ||
* Wrap element | ||
* Wrap the element by adding a wrapper container | ||
*/ | ||
private wrapElement; | ||
/** | ||
* Check visible | ||
* Check visibility of the element | ||
*/ | ||
private checkVisible; | ||
/** | ||
* Create Observer | ||
* Create IntersectionObserver | ||
*/ | ||
private createObserver; | ||
/** | ||
* Observer callback | ||
*/ | ||
private handleIntersect; | ||
/** | ||
* OnEnter | ||
*/ | ||
private onEnter; | ||
/** | ||
* OnLeave | ||
*/ | ||
private onLeave; | ||
@@ -65,5 +55,5 @@ /** | ||
/** | ||
* Set the parallax value to element | ||
* Apply parallax transformation to the element | ||
*/ | ||
private transformParallax; | ||
private applyParallax; | ||
/** | ||
@@ -70,0 +60,0 @@ * Animate parallax |
@@ -1,2 +0,2 @@ | ||
import type { TElement } from '../types/index.ts'; | ||
import type { TElement } from './types.ts'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Check if the current browser supports the required features |
@@ -1,1 +0,1 @@ | ||
var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var r=this.element.getAttribute("src");if(!r)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(r).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),r="absolute"===n.position,o=this.wrapper.style,s=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,r&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(o.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(o.marginTop=n.marginTop,o.marginBottom=n.marginBottom,s.marginTop="0",s.marginBottom="0"),"auto"!==n.inset&&(o.top=n.top,o.right=n.right,o.bottom=n.bottom,o.left=n.left,s.top="0",s.right="0",s.bottom="0",s.left="0"),"none"!==n.transform&&(o.transform=n.transform),"auto"!==n.zIndex&&(o.zIndex=n.zIndex),o.position=r?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(o.gridArea=n.gridArea,s.gridArea="auto"),t&&(o.width="100%",o.overflow="hidden",s.display="block",s.overflow="hidden",s.backfaceVisibility="hidden","0px"!==n.padding&&(s.padding="0"),"img"===this.elementTagName?s.objectFit="cover":"video"!==this.elementTagName&&(s.backgroundPosition="center")),"0px"!==n.borderRadius&&(o.borderRadius=n.borderRadius,o.isolation||(o.isolation="isolate"),"0px"!==n.marginLeft&&(o.marginLeft=n.marginLeft,s.marginLeft="0"),"0px"!==n.marginRight&&(o.marginRight=n.marginRight,s.marginRight="0"),o.width=i+"px"),r&&(o.width=i+"px",s.width="100%"),"none"!==n.maxHeight&&(o.maxHeight=n.maxHeight,s.maxHeight="none"),"0px"!==n.minHeight&&(o.minHeight=n.minHeight,s.minHeight="none"),s.width=i+"px",o.setProperty("height",e+"px","important"),s.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture");if(null!==e)null!==e.parentNode&&e.parentNode.insertBefore(this.wrapper,e),this.wrapper.appendChild(e);else{var i=this.element.parentNode;null!==i&&i.insertBefore(this.wrapper,this.element),this.wrapper.appendChild(this.element)}},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();0<t.bottom&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){this.observer=new IntersectionObserver(this.handleIntersect.bind(this),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.handleIntersect=function(t){t[0].isIntersecting?this.onEnter():this.onLeave()},n.prototype.onEnter=function(){var t=this.element.style;this.options.willChange&&"transform"!==t.willChange&&(t.willChange="transform"),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element.style;this.options.willChange&&"transform"===t.willChange&&(t.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,r=(this.overflow*this.options.speed-this.overflow)/2,o=this.overflow*(1-n)*this.options.speed*this.damp-r;return Number(o.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if((i>=1.4||e>=1.4)&&t<=1e3){e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),r=Math.max(.5,Math.min(1,n));return Math.floor(100*r)/100}return 1},n.prototype.transformParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.transformParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.transformParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var r=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' is null.");var n,r;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=!(!this.options||!this.options.externalRAF)&&this.options.externalRAF,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),r="undefined"!=typeof Element&&Element.prototype.closest,n&&r&&"IntersectionObserver"in window)&&this.init()};r.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},r.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},r.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},r.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},r.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},r.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},r.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1};export{r as default}; | ||
var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var o=this.element.getAttribute("src");if(!o)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(o).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),o="absolute"===n.position,s=this.wrapper.style,r=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,o&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(s.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(s.marginTop=n.marginTop,s.marginBottom=n.marginBottom,r.marginTop="0",r.marginBottom="0"),"auto"!==n.inset&&(s.top=n.top,s.right=n.right,s.bottom=n.bottom,s.left=n.left,r.top="0",r.right="0",r.bottom="0",r.left="0"),"none"!==n.transform&&(s.transform=n.transform),"auto"!==n.zIndex&&(s.zIndex=n.zIndex),s.position=o?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(s.gridArea=n.gridArea,r.gridArea="auto"),t&&(s.width="100%",s.overflow="hidden",r.display="block",r.overflow="hidden",r.backfaceVisibility="hidden","0px"!==n.padding&&(r.padding="0"),"img"===this.elementTagName?r.objectFit="cover":"video"!==this.elementTagName&&(r.backgroundPosition="center")),"0px"!==n.borderRadius&&(s.borderRadius=n.borderRadius,s.isolation||(s.isolation="isolate"),"0px"!==n.marginLeft&&(s.marginLeft=n.marginLeft,r.marginLeft="0"),"0px"!==n.marginRight&&(s.marginRight=n.marginRight,r.marginRight="0"),s.width=i+"px"),o&&(s.width=i+"px",r.width="100%"),"none"!==n.maxHeight&&(s.maxHeight=n.maxHeight,r.maxHeight="none"),"0px"!==n.minHeight&&(s.minHeight=n.minHeight,r.minHeight="none"),r.width=i+"px",s.setProperty("height",e+"px","important"),r.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture"),i=null!==e?e:this.element,n=i.parentNode;null!==n&&n.insertBefore(this.wrapper,i),this.wrapper.appendChild(i)},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();t.bottom>0&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){var t=this;this.observer=new IntersectionObserver((function(e){e[0].isIntersecting?t.onEnter():t.onLeave()}),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.onEnter=function(){var t=this.element.style,e="transform";this.options.willChange&&t.willChange!==e&&(t.willChange=e),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element;this.options.willChange&&"transform"===t.style.willChange&&(t.style.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,o=(this.overflow*this.options.speed-this.overflow)/2,s=this.overflow*(1-n)*this.options.speed*this.damp-o;return Number(s.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if(!(i>=1.4||e>=1.4)||!(t<=1e3))return 1;e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),o=Math.max(.5,Math.min(1,n));return Math.floor(100*o)/100},n.prototype.applyParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.applyParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.applyParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var o=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' cannot be null.");var n,o;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=this.options&&this.options.externalRAF||!1,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),o="undefined"!=typeof Element&&Element.prototype.closest,n&&o&&"IntersectionObserver"in window)&&this.init()};o.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},o.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},o.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},o.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},o.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},o.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},o.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1};export{o as default}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Ukiyo=e()}(this,(function(){"use strict";var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var o=this.element.getAttribute("src");if(!o)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(o).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),o="absolute"===n.position,s=this.wrapper.style,r=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,o&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(s.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(s.marginTop=n.marginTop,s.marginBottom=n.marginBottom,r.marginTop="0",r.marginBottom="0"),"auto"!==n.inset&&(s.top=n.top,s.right=n.right,s.bottom=n.bottom,s.left=n.left,r.top="0",r.right="0",r.bottom="0",r.left="0"),"none"!==n.transform&&(s.transform=n.transform),"auto"!==n.zIndex&&(s.zIndex=n.zIndex),s.position=o?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(s.gridArea=n.gridArea,r.gridArea="auto"),t&&(s.width="100%",s.overflow="hidden",r.display="block",r.overflow="hidden",r.backfaceVisibility="hidden","0px"!==n.padding&&(r.padding="0"),"img"===this.elementTagName?r.objectFit="cover":"video"!==this.elementTagName&&(r.backgroundPosition="center")),"0px"!==n.borderRadius&&(s.borderRadius=n.borderRadius,s.isolation||(s.isolation="isolate"),"0px"!==n.marginLeft&&(s.marginLeft=n.marginLeft,r.marginLeft="0"),"0px"!==n.marginRight&&(s.marginRight=n.marginRight,r.marginRight="0"),s.width=i+"px"),o&&(s.width=i+"px",r.width="100%"),"none"!==n.maxHeight&&(s.maxHeight=n.maxHeight,r.maxHeight="none"),"0px"!==n.minHeight&&(s.minHeight=n.minHeight,r.minHeight="none"),r.width=i+"px",s.setProperty("height",e+"px","important"),r.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture");if(null!==e)null!==e.parentNode&&e.parentNode.insertBefore(this.wrapper,e),this.wrapper.appendChild(e);else{var i=this.element.parentNode;null!==i&&i.insertBefore(this.wrapper,this.element),this.wrapper.appendChild(this.element)}},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();0<t.bottom&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){this.observer=new IntersectionObserver(this.handleIntersect.bind(this),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.handleIntersect=function(t){t[0].isIntersecting?this.onEnter():this.onLeave()},n.prototype.onEnter=function(){var t=this.element.style;this.options.willChange&&"transform"!==t.willChange&&(t.willChange="transform"),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element.style;this.options.willChange&&"transform"===t.willChange&&(t.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,o=(this.overflow*this.options.speed-this.overflow)/2,s=this.overflow*(1-n)*this.options.speed*this.damp-o;return Number(s.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if((i>=1.4||e>=1.4)&&t<=1e3){e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),o=Math.max(.5,Math.min(1,n));return Math.floor(100*o)/100}return 1},n.prototype.transformParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.transformParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.transformParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var o=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' is null.");var n,o;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=!(!this.options||!this.options.externalRAF)&&this.options.externalRAF,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),o="undefined"!=typeof Element&&Element.prototype.closest,n&&o&&"IntersectionObserver"in window)&&this.init()};return o.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},o.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},o.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},o.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},o.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},o.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},o.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1},o})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Ukiyo=e()}(this,(function(){"use strict";var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var o=this.element.getAttribute("src");if(!o)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(o).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),o="absolute"===n.position,s=this.wrapper.style,r=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,o&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(s.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(s.marginTop=n.marginTop,s.marginBottom=n.marginBottom,r.marginTop="0",r.marginBottom="0"),"auto"!==n.inset&&(s.top=n.top,s.right=n.right,s.bottom=n.bottom,s.left=n.left,r.top="0",r.right="0",r.bottom="0",r.left="0"),"none"!==n.transform&&(s.transform=n.transform),"auto"!==n.zIndex&&(s.zIndex=n.zIndex),s.position=o?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(s.gridArea=n.gridArea,r.gridArea="auto"),t&&(s.width="100%",s.overflow="hidden",r.display="block",r.overflow="hidden",r.backfaceVisibility="hidden","0px"!==n.padding&&(r.padding="0"),"img"===this.elementTagName?r.objectFit="cover":"video"!==this.elementTagName&&(r.backgroundPosition="center")),"0px"!==n.borderRadius&&(s.borderRadius=n.borderRadius,s.isolation||(s.isolation="isolate"),"0px"!==n.marginLeft&&(s.marginLeft=n.marginLeft,r.marginLeft="0"),"0px"!==n.marginRight&&(s.marginRight=n.marginRight,r.marginRight="0"),s.width=i+"px"),o&&(s.width=i+"px",r.width="100%"),"none"!==n.maxHeight&&(s.maxHeight=n.maxHeight,r.maxHeight="none"),"0px"!==n.minHeight&&(s.minHeight=n.minHeight,r.minHeight="none"),r.width=i+"px",s.setProperty("height",e+"px","important"),r.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture"),i=null!==e?e:this.element,n=i.parentNode;null!==n&&n.insertBefore(this.wrapper,i),this.wrapper.appendChild(i)},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();t.bottom>0&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){var t=this;this.observer=new IntersectionObserver((function(e){e[0].isIntersecting?t.onEnter():t.onLeave()}),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.onEnter=function(){var t=this.element.style,e="transform";this.options.willChange&&t.willChange!==e&&(t.willChange=e),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element;this.options.willChange&&"transform"===t.style.willChange&&(t.style.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,o=(this.overflow*this.options.speed-this.overflow)/2,s=this.overflow*(1-n)*this.options.speed*this.damp-o;return Number(s.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if(!(i>=1.4||e>=1.4)||!(t<=1e3))return 1;e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),o=Math.max(.5,Math.min(1,n));return Math.floor(100*o)/100},n.prototype.applyParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.applyParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.applyParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var o=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' cannot be null.");var n,o;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=this.options&&this.options.externalRAF||!1,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),o="undefined"!=typeof Element&&Element.prototype.closest,n&&o&&"IntersectionObserver"in window)&&this.init()};return o.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},o.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},o.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},o.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},o.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},o.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},o.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1},o})); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Ukiyo=e()}(this,(function(){"use strict";var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var o=this.element.getAttribute("src");if(!o)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(o).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),o="absolute"===n.position,s=this.wrapper.style,r=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,o&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(s.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(s.marginTop=n.marginTop,s.marginBottom=n.marginBottom,r.marginTop="0",r.marginBottom="0"),"auto"!==n.inset&&(s.top=n.top,s.right=n.right,s.bottom=n.bottom,s.left=n.left,r.top="0",r.right="0",r.bottom="0",r.left="0"),"none"!==n.transform&&(s.transform=n.transform),"auto"!==n.zIndex&&(s.zIndex=n.zIndex),s.position=o?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(s.gridArea=n.gridArea,r.gridArea="auto"),t&&(s.width="100%",s.overflow="hidden",r.display="block",r.overflow="hidden",r.backfaceVisibility="hidden","0px"!==n.padding&&(r.padding="0"),"img"===this.elementTagName?r.objectFit="cover":"video"!==this.elementTagName&&(r.backgroundPosition="center")),"0px"!==n.borderRadius&&(s.borderRadius=n.borderRadius,s.isolation||(s.isolation="isolate"),"0px"!==n.marginLeft&&(s.marginLeft=n.marginLeft,r.marginLeft="0"),"0px"!==n.marginRight&&(s.marginRight=n.marginRight,r.marginRight="0"),s.width=i+"px"),o&&(s.width=i+"px",r.width="100%"),"none"!==n.maxHeight&&(s.maxHeight=n.maxHeight,r.maxHeight="none"),"0px"!==n.minHeight&&(s.minHeight=n.minHeight,r.minHeight="none"),r.width=i+"px",s.setProperty("height",e+"px","important"),r.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture");if(null!==e)null!==e.parentNode&&e.parentNode.insertBefore(this.wrapper,e),this.wrapper.appendChild(e);else{var i=this.element.parentNode;null!==i&&i.insertBefore(this.wrapper,this.element),this.wrapper.appendChild(this.element)}},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();0<t.bottom&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){this.observer=new IntersectionObserver(this.handleIntersect.bind(this),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.handleIntersect=function(t){t[0].isIntersecting?this.onEnter():this.onLeave()},n.prototype.onEnter=function(){var t=this.element.style;this.options.willChange&&"transform"!==t.willChange&&(t.willChange="transform"),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element.style;this.options.willChange&&"transform"===t.willChange&&(t.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,o=(this.overflow*this.options.speed-this.overflow)/2,s=this.overflow*(1-n)*this.options.speed*this.damp-o;return Number(s.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if((i>=1.4||e>=1.4)&&t<=1e3){e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),o=Math.max(.5,Math.min(1,n));return Math.floor(100*o)/100}return 1},n.prototype.transformParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.transformParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.transformParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var o=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' is null.");var n,o;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=!(!this.options||!this.options.externalRAF)&&this.options.externalRAF,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),o="undefined"!=typeof Element&&Element.prototype.closest,n&&o&&"IntersectionObserver"in window)&&this.init()};return o.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},o.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},o.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},o.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},o.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},o.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},o.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1},o})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Ukiyo=e()}(this,(function(){"use strict";var t=function(t){return Array.prototype.slice.call(t)},e=function(){var t=window.navigator.userAgent,e=!!t.match(/iPad/i)||!!t.match(/iPhone/i),i=!!t.match(/WebKit/i);return e&&i&&!t.match(/CriOS/i)},i={scale:1.5,speed:1.5,wrapperClass:null,willChange:!1,externalRAF:!1},n=function(t,e){var n=this;if(this.element=t,this.wrapper=document.createElement("div"),this.options=Object.assign({},i,e),this.updateOptions(),this.vh=document.documentElement.clientHeight,this.isVisible=!1,this.damp=this.calcDamp(document.documentElement.clientWidth),this.elementTagName=this.element.tagName.toLowerCase(),"img"===this.elementTagName){var o=this.element.getAttribute("src");if(!o)return;(async function(t){var e=new Image;return e.src=t,await e.decode(),e})(o).then((function(){n.createParallax()}))}else this.createParallax()};n.prototype.createParallax=function(){this.setStyle(!0),this.wrapElement(),e()||this.createObserver()},n.prototype.updateOptions=function(){var t=this.element.getAttribute("data-u-scale"),e=this.element.getAttribute("data-u-speed"),i=this.element.getAttribute("data-u-willchange");null!==t&&(this.options.scale=Number(t)),null!==e&&(this.options.speed=Number(e)),null!==i&&(this.options.willChange=!0)},n.prototype.setStyle=function(t){void 0===t&&(t=!1);var e=this.element.clientHeight,i=this.element.clientWidth,n=window.getComputedStyle(this.element),o="absolute"===n.position,s=this.wrapper.style,r=this.element.style;this.overflow=Math.floor(10*(e-e*this.options.scale))/10,o&&"0px"!==n.marginRight&&"0px"!==n.marginLeft&&n.marginLeft===n.marginRight&&(s.margin="auto"),"0px"===n.marginTop&&"0px"===n.marginBottom||(s.marginTop=n.marginTop,s.marginBottom=n.marginBottom,r.marginTop="0",r.marginBottom="0"),"auto"!==n.inset&&(s.top=n.top,s.right=n.right,s.bottom=n.bottom,s.left=n.left,r.top="0",r.right="0",r.bottom="0",r.left="0"),"none"!==n.transform&&(s.transform=n.transform),"auto"!==n.zIndex&&(s.zIndex=n.zIndex),s.position=o?"absolute":"relative","auto"!==n.gridArea&&"auto / auto / auto / auto"!==n.gridArea&&(s.gridArea=n.gridArea,r.gridArea="auto"),t&&(s.width="100%",s.overflow="hidden",r.display="block",r.overflow="hidden",r.backfaceVisibility="hidden","0px"!==n.padding&&(r.padding="0"),"img"===this.elementTagName?r.objectFit="cover":"video"!==this.elementTagName&&(r.backgroundPosition="center")),"0px"!==n.borderRadius&&(s.borderRadius=n.borderRadius,s.isolation||(s.isolation="isolate"),"0px"!==n.marginLeft&&(s.marginLeft=n.marginLeft,r.marginLeft="0"),"0px"!==n.marginRight&&(s.marginRight=n.marginRight,r.marginRight="0"),s.width=i+"px"),o&&(s.width=i+"px",r.width="100%"),"none"!==n.maxHeight&&(s.maxHeight=n.maxHeight,r.maxHeight="none"),"0px"!==n.minHeight&&(s.minHeight=n.minHeight,r.minHeight="none"),r.width=i+"px",s.setProperty("height",e+"px","important"),r.setProperty("height",e*this.options.scale+"px","important"),this.wrapperHeight=e},n.prototype.wrapElement=function(){var t=this.element.getAttribute("data-u-wrapper-class")||this.options.wrapperClass;t&&this.wrapper.classList.add(t);var e=this.element.closest("picture"),i=null!==e?e:this.element,n=i.parentNode;null!==n&&n.insertBefore(this.wrapper,i),this.wrapper.appendChild(i)},n.prototype.checkVisible=function(){var t=this.wrapper.getBoundingClientRect();t.bottom>0&&t.top<window.innerHeight?this.onEnter():this.onLeave()},n.prototype.createObserver=function(){var t=this;this.observer=new IntersectionObserver((function(e){e[0].isIntersecting?t.onEnter():t.onLeave()}),{root:null,rootMargin:"0px",threshold:0}),this.observer.observe(this.wrapper)},n.prototype.onEnter=function(){var t=this.element.style,e="transform";this.options.willChange&&t.willChange!==e&&(t.willChange=e),this.isVisible=!0},n.prototype.onLeave=function(){var t=this.element;this.options.willChange&&"transform"===t.style.willChange&&(t.style.willChange=""),this.isVisible=!1},n.prototype.calcTranslateValue=function(){var t=window.pageYOffset;t<0&&(t=0);var e=this.wrapper.getBoundingClientRect().top+t,i=(t+this.vh-e)/((this.vh+this.wrapperHeight)/100),n=Math.min(100,Math.max(0,i))/100,o=(this.overflow*this.options.speed-this.overflow)/2,s=this.overflow*(1-n)*this.options.speed*this.damp-o;return Number(s.toFixed(4))},n.prototype.calcDamp=function(t){var e=this.options.scale,i=this.options.speed;if(!(i>=1.4||e>=1.4)||!(t<=1e3))return 1;e<1&&(e=1),i<1&&(i=1);var n=1.2-(1-(t/1e3+(3-(e+i)))),o=Math.max(.5,Math.min(1,n));return Math.floor(100*o)/100},n.prototype.applyParallax=function(){this.element.style.transform="translate3d(0 , "+this.calcTranslateValue()+"px , 0)"},n.prototype.animate=function(){e()&&this.checkVisible(),window.pageYOffset<0||this.isVisible&&this.applyParallax()},n.prototype.reset=function(){this.damp=this.calcDamp(window.innerWidth);var t=this.wrapper.style,e=this.element.style;this.vh=document.documentElement.clientHeight,t.width="",t.position="",t.height="100%",e.width="","img"===this.elementTagName&&"absolute"===t.position&&(t.height="100%"),""===t.gridArea?e.height="":e.height="100%","0px"!==t.margin&&(t.margin="",e.margin=""),"auto"!==t.inset&&(t.top="",t.right="",t.bottom="",t.left="",e.top="",e.right="",e.bottom="",e.left=""),"none"!==t.transform&&(t.transform="",e.transform=""),"auto"!==t.zIndex&&(t.zIndex=""),"0px"!==t.borderRadius&&(t.borderRadius="",t.isolation=""),this.setStyle(),this.applyParallax()},n.prototype.destroy=function(){var t;this.observer&&this.observer.disconnect(),this.wrapper.removeAttribute("style"),this.element.removeAttribute("style"),(t=this.wrapper).replaceWith.apply(t,this.wrapper.childNodes)};var o=function(e,i){if(this.elements=[],!e)throw new Error("Argument 'elements' cannot be null.");var n,o;(this.elements=function(e){return Array.isArray(e)?e:"string"==typeof e?t(document.querySelectorAll(e)):e instanceof HTMLElement?[e]:e instanceof NodeList||e instanceof HTMLCollection?t(e):[e]}(e),this.options=i,this.instances=[],this.externalRAF=this.options&&this.options.externalRAF||!1,this.onResizeEvent=this.resize.bind(this),this.isInit=!1,n="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]"),o="undefined"!=typeof Element&&Element.prototype.closest,n&&o&&"IntersectionObserver"in window)&&this.init()};return o.prototype.init=function(){var t=this;this.isInit||(this.instances=this.elements.map((function(e){return new n(e,t.options)})),this.externalRAF||this.animate(),this.addEventListeners(),this.isInit=!0)},o.prototype.animate=function(){this.instances.forEach((function(t){t.animate()})),this.externalRAF||(this.requestId=window.requestAnimationFrame(this.animate.bind(this)))},o.prototype.cancel=function(){this.requestId&&window.cancelAnimationFrame(this.requestId)},o.prototype.reset=function(){this.instances.forEach((function(t){t.reset()}))},o.prototype.resize=function(){clearTimeout(this.timer),this.timer=window.setTimeout(this.reset.bind(this),500),this.reset.bind(this)},o.prototype.addEventListeners=function(){navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)?window.addEventListener("orientationchange",this.onResizeEvent):window.addEventListener("resize",this.onResizeEvent)},o.prototype.destroy=function(){this.cancel(),window.removeEventListener("resize",this.onResizeEvent),window.removeEventListener("orientationchange",this.onResizeEvent),this.instances.forEach((function(t){t.destroy()})),this.isInit=!1},o})); |
{ | ||
"name": "ukiyojs", | ||
"version": "4.0.9", | ||
"version": "4.1.0", | ||
"description": "Modern parallax library for picture elements and any images", | ||
@@ -34,10 +34,11 @@ "homepage": "https://yitengjun.github.io/ukiyo-js/", | ||
], | ||
"author": "Yiteng Jun <ito.yitengjun@gmail.com>", | ||
"author": "Yiteng Jun <yiteng.work@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "rollup -c -w", | ||
"serve": "browser-sync start --config \"./.bs-config.cjs\"", | ||
"test": "vitest", | ||
"format": "prettier --write \"./src/**/*.ts\" \"./{*.cjs,*.ts,*.js,*.json}\" \"./tests/**/*.ts\" \"./docs/**/{*.html,*.css}\" \"./tests/src/**/{*.html,*.css}\"", | ||
"lint": "eslint \"./src/**/*.ts\" --fix", | ||
"build": "rollup -c", | ||
"lint": "eslint \"./src/**/*.ts\" --fix", | ||
"format": "prettier --write \"./src/**/*.ts\" \"./types/**/*.ts\"", | ||
"serve": "browser-sync start --config \"./.bs-config.cjs\"", | ||
"semantic-release": "semantic-release" | ||
@@ -59,2 +60,3 @@ }, | ||
"eslint-config-prettier": "^8.5.0", | ||
"happy-dom": "^10.0.3", | ||
"prettier": "^2.8.8", | ||
@@ -64,3 +66,4 @@ "rollup": "^2.79.1", | ||
"tslib": "^2.4.1", | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.0.4", | ||
"vitest": "^0.33.0" | ||
}, | ||
@@ -67,0 +70,0 @@ "release": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34322
11
253
20
1