From 17c5078f33a6d129dc1a706b244494fa92991c07 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sat, 16 Apr 2022 20:27:12 -0500 Subject: [PATCH 01/32] #69: WIP - move code into separate classes --- src/pushinLayer.ts | 315 +++++++++++++++++++++++++++++++++ src/pushinScene.ts | 421 +++++++++++++++++++++++++++++++++++++++++++++ src/types.ts | 22 +-- 3 files changed, 748 insertions(+), 10 deletions(-) create mode 100644 src/pushinLayer.ts create mode 100644 src/pushinScene.ts diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts new file mode 100644 index 0000000..6463f21 --- /dev/null +++ b/src/pushinLayer.ts @@ -0,0 +1,315 @@ +import { + DEFAULT_SPEED, + PUSH_IN_TO_DATA_ATTRIBUTE, + PUSH_IN_FROM_DATA_ATTRIBUTE, + PUSH_IN_SPEED_DATA_ATTRIBUTE, +} from './constants'; + +import { LayerOptions, LayerRef, LayerParams } from './types'; + +export class PushInLayer { + private originalScale: number; + private ref: LayerRef; + private params: LayerParams; + + constructor( + private element: HTMLElement, + private index: number, + private scene: HTMLElement, + private options: LayerOptions | null + ) { + const inpoints = this.getInpoints(this.element, this.index); + const outpoints = this.getOutpoints(this.element, inpoints[0]); + const speed = this.getSpeed(this.element, this.index); + + this.originalScale = this.getElementScaleX(element); + this.ref = { inpoints, outpoints, speed }; + + this.params = { + inpoint: this.getInpoint(inpoints), + outpoint: this.getOutpoint(outpoints), + speed, + }; + } + + /** + * Get all inpoints for the layer. + */ + private getInpoints(element: HTMLElement, index: number): number[] { + const { top } = this.scene.getBoundingClientRect(); + + let inpoints = [top]; + if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map( + inpoint => parseInt(inpoint.trim(), 10) + ); + } else if (this.options?.inpoints) { + inpoints = this.options.inpoints; + } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + // Custom inpoint + inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split( + ',' + ).map(inpoint => parseInt(inpoint.trim(), 10)); + } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) { + inpoints = this.sceneOptions.inpoints; + } else if (index > 0) { + // Set default for middle layers if none provided + const { outpoint } = this.layers[index - 1].params; + inpoints = [outpoint - this.speedDelta]; + } + + return inpoints; + } + + /** + * Get all outpoints for the layer. + */ + private getOutpoints(element: HTMLElement, inpoint: number): number[] { + let outpoints = [inpoint + this.layerDepth]; + + if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { + const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(','); + outpoints = values.map(value => parseInt(value.trim(), 10)); + } else if (this.options?.outpoints) { + outpoints = this.options.outpoints; + } + + return outpoints; + } + + /** + * Get the push-in speed for the layer. + */ + private getSpeed(element: HTMLElement, index: number): number { + let speed: number | null = null; + + if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { + speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10); + if (Number.isNaN(speed)) { + speed = DEFAULT_SPEED; + } + } else if (this.options?.speed) { + speed = this.options.speed; + } + + return speed || DEFAULT_SPEED; + } + + /** + * Get the array index of the current window breakpoint. + */ + private getBreakpointIndex(): number { + const searchIndex = this.sceneOptions.breakpoints + .reverse() + .findIndex(bp => bp <= window.innerWidth); + return searchIndex === -1 + ? 0 + : this.sceneOptions.breakpoints.length - 1 - searchIndex; + } + + /** + * Set the z-index of each layer so they overlap correctly. + */ + setZIndex(layer: PushInLayer, total: number): void { + layer.element.style.zIndex = (total - layer.index).toString(); + } + + /** + * Reset all the layer parameters. + * + * This is used if the window is resized + * and things need to be recalculated. + */ + private resetLayerParams(): void { + this.params = { + inpoint: this.getInpoint(this.ref.inpoints), + outpoint: this.getOutpoint(this.ref.outpoints), + speed: this.ref.speed, + }; + } + + /** + * Get the initial scale of the element at time of DOM load. + */ + private getElementScaleX(element: HTMLElement): number { + const transform = window + .getComputedStyle(element) + .getPropertyValue('transform'); + + let scaleX = 1; + if (transform && transform !== 'none') { + const match = transform.match(/[matrix|scale]\(([\d,.\s]+)/); + if (match && match[1]) { + const matrix = match[1].split(', '); + scaleX = parseFloat(matrix[0]); + } + } + + return scaleX; + } + + /** + * Animation effect, mimicking a camera dolly on the webpage. + */ + private dolly(): void { + cancelAnimationFrame(this.lastAnimationFrameId); + + this.lastAnimationFrameId = requestAnimationFrame(() => { + this.toggleLayers(); + }); + } + + /** + * Show or hide layers and set their scale, depending on if active. + */ + private toggleLayers(): void { + this.layers.forEach(layer => this.setLayerStyle(layer)); + } + + /** + * Whether or not a layer should currently be zooming. + */ + private isActive(layer: PushInLayer): boolean { + const { inpoint } = layer.params; + const { outpoint } = layer.params; + return this.scrollPos >= inpoint && this.scrollPos <= outpoint; + } + + /** + * Get the current inpoint for a layer, + * depending on window breakpoint. + */ + private getInpoint(inpoints: number[]): number { + return inpoints[this.getBreakpointIndex()] || inpoints[0]; + } + + /** + * Get the current outpoint for a layer, + * depending on window breakpoint. + */ + private getOutpoint(outpoints: number[]): number { + return outpoints[this.getBreakpointIndex()] || outpoints[0]; + } + + /** + * Get the scaleX value for the layer. + */ + private getScaleValue(layer: PushInLayer): number { + const distance = this.scrollPos - layer.params.inpoint; + const speed = Math.min(layer.params.speed, 100) / 100; + const delta = (distance * speed) / 100; + + return Math.max(layer.originalScale + delta, 0); + } + + /** + * Set element scale. + */ + private setScale({ style }: HTMLElement, value: number): void { + const scaleString = `scale(${value})`; + style.webkitTransform = scaleString; + (style as unknown as { mozTransform: string }).mozTransform = scaleString; + (style as unknown as { msTransform: string }).msTransform = scaleString; + (style as unknown as { oTransform: string }).oTransform = scaleString; + style.transform = scaleString; + } + + /** + * Set CSS styles to control the effect on each layer. + * + * This will control the scale and opacity of the layer + * as the user scrolls. + */ + private setLayerStyle(layer: PushInLayer): void { + let opacity = 0; + const isFirst = layer.index === 0; + const isLast = layer.index + 1 === this.layers.length; + const { inpoint } = layer.params; + const { outpoint } = layer.params; + + if (isFirst && this.scrollPos < inpoint) { + opacity = 1; + } else if (isLast && this.scrollPos > outpoint) { + opacity = 1; + } else if (this.isActive(layer)) { + this.setScale(layer.element, this.getScaleValue(layer)); + + let inpointDistance = + Math.max(Math.min(this.scrollPos - inpoint, this.transitionLength), 0) / + this.transitionLength; + + // Set opacity to 1 if its the first layer and it is active (no fading in here) + if (isFirst) { + inpointDistance = 1; + } + + let outpointDistance = + Math.max( + Math.min(outpoint - this.scrollPos, this.transitionLength), + 0 + ) / this.transitionLength; + + // Set opacity to 1 if its the last layer and it is active (no fading out) + if (isLast) { + outpointDistance = 1; + } + + opacity = Math.min(inpointDistance, outpointDistance); + } + + layer.element.style.opacity = opacity.toString(); + } + + /** + * Set the default container height based on a few factors: + * 1. Number of layers present + * 2. The transition length between layers + * 3. The length of scrolling time during each layer + * + * If this calculation is smaller than the container's current height, + * the current height will be used instead. + */ + private setScrollLength(): void { + const containerHeight = getComputedStyle(this.container).height.replace( + 'px', + '' + ); + + const transitions = (this.layers.length - 1) * this.speedDelta; + const scrollLength = + this.layers.length * (this.layerDepth + this.transitionLength); + + this.container.style.height = `${Math.max( + parseFloat(containerHeight), + scrollLength - transitions + )}px`; + } + + /** + * Show a debugging tool appended to the frontend of the page. + * Can be used to determine best "pushin-from" and "pushin-to" values. + */ + private showDebugger(): void { + const scrollCounter = document.createElement('div'); + scrollCounter.classList.add('pushin-debug'); + + const scrollTitle = document.createElement('p'); + scrollTitle.innerText = 'Pushin.js Debugger'; + scrollTitle.classList.add('pushin-debug__title'); + + const debuggerContent = document.createElement('div'); + debuggerContent.classList.add('pushin-debug__content'); + debuggerContent.innerText = `Scroll position: ${window.pageYOffset}px`; + + scrollCounter.appendChild(scrollTitle); + scrollCounter.appendChild(debuggerContent); + + document.body.appendChild(scrollCounter); + + window.addEventListener('scroll', () => { + debuggerContent.innerText = `Scroll position: ${Math.round( + window.pageYOffset + )}px`; + }); + } +} diff --git a/src/pushinScene.ts b/src/pushinScene.ts new file mode 100644 index 0000000..097b1e7 --- /dev/null +++ b/src/pushinScene.ts @@ -0,0 +1,421 @@ +import { + DEFAULT_SPEED, + PUSH_IN_TO_DATA_ATTRIBUTE, + PUSH_IN_FROM_DATA_ATTRIBUTE, + PUSH_IN_SPEED_DATA_ATTRIBUTE, + PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE, +} from './constants'; +import { PushInLayer } from './pushinLayer'; + +import { SceneOptions, LayerOptions } from './types'; + +export class PushInScene { + private container: HTMLElement; + private readonly cleanupFns: VoidFunction[] = []; + + constructor(private parent: HTMLElement, private options?: SceneOptions, private layerOptions?: LayerOptions ) { + const container = this.parent.querySelector('.pushin-scene'); + + if (container) { + this.container = container; + } else { + this.container = document.createElement('div'); + this.container.classList.add('pushin-scene'); + + this.container.innerHTML = this.parent.innerHTML; + this.parent.innerHTML = ''; + this.parent.appendChild(this.container); + this.cleanupFns.push(() => this.container.removeChild(this.container)); + } + + this.getLayers(); + } + + /** + * Set breakpoints for responsive design settings. + */ + private setBreakpoints(): void { + if (this.options?.breakpoints.length === 0) { + this.options.breakpoints = [768, 1440, 1920]; + } + + if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { + this.options!.breakpoints = this.container.dataset[ + PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE + ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); + } + + // Always include break point 0 for anything under first breakpoint + this.options!.breakpoints.unshift(0); + } + + /** + * Find all layers on the page and store them with their parameters + */ + private getLayers(): void { + const layers = Array.from( + this.container.getElementsByClassName('pushin-layer') + ); + + for (let index = 0; index < layers.length; index++) { + const element = layers[index]; + const layerOptions = this.layerOptions ?? {}; + const layer = new PushInLayer( + element, + index, + this.container, + layerOptions + ); + this.layers.push(layer); + this.setZIndex(layer, layers.length); + } + } + + /** + * Get all inpoints for the layer. + */ + private getInpoints(element: HTMLElement, index: number): number[] { + const { top } = this.scene.getBoundingClientRect(); + + let inpoints = [top]; + if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map( + inpoint => parseInt(inpoint.trim(), 10) + ); + } else if (this.layerOptions[index]?.inpoints) { + inpoints = this.layerOptions[index].inpoints; + } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + // Custom inpoint + inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split( + ',' + ).map(inpoint => parseInt(inpoint.trim(), 10)); + } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) { + inpoints = this.sceneOptions.inpoints; + } else if (index > 0) { + // Set default for middle layers if none provided + const { outpoint } = this.layers[index - 1].params; + inpoints = [outpoint - this.speedDelta]; + } + + return inpoints; + } + + /** + * Get all outpoints for the layer. + */ + private getOutpoints( + element: HTMLElement, + inpoint: number, + index: number + ): number[] { + let outpoints = [inpoint + this.layerDepth]; + + if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { + const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(','); + outpoints = values.map(value => parseInt(value.trim(), 10)); + } else if (this.layerOptions[index]?.outpoints) { + outpoints = this.layerOptions[index].outpoints; + } + + return outpoints; + } + + /** + * Get the push-in speed for the layer. + */ + private getSpeed(element: HTMLElement, index: number): number { + let speed: number | null = null; + + if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { + speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10); + if (Number.isNaN(speed)) { + speed = DEFAULT_SPEED; + } + } else if (this.layerOptions[index]?.speed) { + speed = this.layerOptions[index].speed; + } + + return speed || DEFAULT_SPEED; + } + + /** + * Get the array index of the current window breakpoint. + */ + private getBreakpointIndex(): number { + const searchIndex = this.sceneOptions.breakpoints + .reverse() + .findIndex(bp => bp <= window.innerWidth); + return searchIndex === -1 + ? 0 + : this.sceneOptions.breakpoints.length - 1 - searchIndex; + } + + /** + * Set the z-index of each layer so they overlap correctly. + */ + private setZIndex(layer: PushInLayer, total: number): void { + layer.element.style.zIndex = (total - layer.index).toString(); + } + + /** + * Bind event listeners to watch for page load and user interaction. + */ + private bindEvents(): void { + const onScroll = () => { + this.scrollPos = window.pageYOffset; + this.dolly(); + }; + window.addEventListener('scroll', onScroll); + this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); + + const onTouchstart = (event: TouchEvent) => { + this.touchStart = event.changedTouches[0].screenY; + }; + window.addEventListener('touchstart', onTouchstart); + this.cleanupFns.push(() => + window.removeEventListener('touchstart', onTouchstart) + ); + + const onTouchmove = (event: TouchEvent) => { + event.preventDefault(); + + const touchMove = event.changedTouches[0].screenY; + this.scrollPos = Math.max( + this.scrollEnd! + this.touchStart! - touchMove, + 0 + ); + this.scrollPos = Math.min( + this.scrollPos, + this.pageHeight! - window.innerHeight + ); + + this.dolly(); + }; + window.addEventListener('touchmove', onTouchmove); + this.cleanupFns.push(() => + window.removeEventListener('touchmove', onTouchmove) + ); + + const onTouchend = () => { + this.scrollEnd = this.scrollPos; + }; + window.addEventListener('touchend', onTouchend); + this.cleanupFns.push(() => + window.removeEventListener('touchend', onTouchend) + ); + + let resizeTimeout: number; + const onResize = () => { + clearTimeout(resizeTimeout); + + resizeTimeout = window.setTimeout(() => { + this.resetLayerParams(); + this.setScrollLength(); + this.toggleLayers(); + }, 300); + }; + window.addEventListener('resize', onResize); + this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); + } + + /** + * Reset all the layer parameters. + * + * This is used if the window is resized + * and things need to be recalculated. + */ + private resetLayerParams(): void { + this.layers.forEach(layer => { + layer.params = { + inpoint: this.getInpoint(layer.ref.inpoints), + outpoint: this.getOutpoint(layer.ref.outpoints), + speed: layer.ref.speed, + }; + }); + } + + /** + * Get the initial scale of the element at time of DOM load. + */ + private getElementScaleX(element: HTMLElement): number { + const transform = window + .getComputedStyle(element) + .getPropertyValue('transform'); + + let scaleX = 1; + if (transform && transform !== 'none') { + const match = transform.match(/[matrix|scale]\(([\d,.\s]+)/); + if (match && match[1]) { + const matrix = match[1].split(', '); + scaleX = parseFloat(matrix[0]); + } + } + + return scaleX; + } + + /** + * Animation effect, mimicking a camera dolly on the webpage. + */ + private dolly(): void { + cancelAnimationFrame(this.lastAnimationFrameId); + + this.lastAnimationFrameId = requestAnimationFrame(() => { + this.toggleLayers(); + }); + } + + /** + * Show or hide layers and set their scale, depending on if active. + */ + private toggleLayers(): void { + this.layers.forEach(layer => this.setLayerStyle(layer)); + } + + /** + * Whether or not a layer should currently be zooming. + */ + private isActive(layer: PushInLayer): boolean { + const { inpoint } = layer.params; + const { outpoint } = layer.params; + return this.scrollPos >= inpoint && this.scrollPos <= outpoint; + } + + /** + * Get the current inpoint for a layer, + * depending on window breakpoint. + */ + private getInpoint(inpoints: number[]): number { + return inpoints[this.getBreakpointIndex()] || inpoints[0]; + } + + /** + * Get the current outpoint for a layer, + * depending on window breakpoint. + */ + private getOutpoint(outpoints: number[]): number { + return outpoints[this.getBreakpointIndex()] || outpoints[0]; + } + + /** + * Get the scaleX value for the layer. + */ + private getScaleValue(layer: PushInLayer): number { + const distance = this.scrollPos - layer.params.inpoint; + const speed = Math.min(layer.params.speed, 100) / 100; + const delta = (distance * speed) / 100; + + return Math.max(layer.originalScale + delta, 0); + } + + /** + * Set element scale. + */ + private setScale({ style }: HTMLElement, value: number): void { + const scaleString = `scale(${value})`; + style.webkitTransform = scaleString; + (style as unknown as { mozTransform: string }).mozTransform = scaleString; + (style as unknown as { msTransform: string }).msTransform = scaleString; + (style as unknown as { oTransform: string }).oTransform = scaleString; + style.transform = scaleString; + } + + /** + * Set CSS styles to control the effect on each layer. + * + * This will control the scale and opacity of the layer + * as the user scrolls. + */ + private setLayerStyle(layer: PushInLayer): void { + let opacity = 0; + const isFirst = layer.index === 0; + const isLast = layer.index + 1 === this.layers.length; + const { inpoint } = layer.params; + const { outpoint } = layer.params; + + if (isFirst && this.scrollPos < inpoint) { + opacity = 1; + } else if (isLast && this.scrollPos > outpoint) { + opacity = 1; + } else if (this.isActive(layer)) { + this.setScale(layer.element, this.getScaleValue(layer)); + + let inpointDistance = + Math.max(Math.min(this.scrollPos - inpoint, this.transitionLength), 0) / + this.transitionLength; + + // Set opacity to 1 if its the first layer and it is active (no fading in here) + if (isFirst) { + inpointDistance = 1; + } + + let outpointDistance = + Math.max( + Math.min(outpoint - this.scrollPos, this.transitionLength), + 0 + ) / this.transitionLength; + + // Set opacity to 1 if its the last layer and it is active (no fading out) + if (isLast) { + outpointDistance = 1; + } + + opacity = Math.min(inpointDistance, outpointDistance); + } + + layer.element.style.opacity = opacity.toString(); + } + + /** + * Set the default container height based on a few factors: + * 1. Number of layers present + * 2. The transition length between layers + * 3. The length of scrolling time during each layer + * + * If this calculation is smaller than the container's current height, + * the current height will be used instead. + */ + private setScrollLength(): void { + const containerHeight = getComputedStyle(this.container).height.replace( + 'px', + '' + ); + + const transitions = (this.layers.length - 1) * this.speedDelta; + const scrollLength = + this.layers.length * (this.layerDepth + this.transitionLength); + + this.container.style.height = `${Math.max( + parseFloat(containerHeight), + scrollLength - transitions + )}px`; + } + + /** + * Show a debugging tool appended to the frontend of the page. + * Can be used to determine best "pushin-from" and "pushin-to" values. + */ + private showDebugger(): void { + const scrollCounter = document.createElement('div'); + scrollCounter.classList.add('pushin-debug'); + + const scrollTitle = document.createElement('p'); + scrollTitle.innerText = 'Pushin.js Debugger'; + scrollTitle.classList.add('pushin-debug__title'); + + const debuggerContent = document.createElement('div'); + debuggerContent.classList.add('pushin-debug__content'); + debuggerContent.innerText = `Scroll position: ${window.pageYOffset}px`; + + scrollCounter.appendChild(scrollTitle); + scrollCounter.appendChild(debuggerContent); + + document.body.appendChild(scrollCounter); + + window.addEventListener('scroll', () => { + debuggerContent.innerText = `Scroll position: ${Math.round( + window.pageYOffset + )}px`; + }); + } +} diff --git a/src/types.ts b/src/types.ts index 87b95ca..3011113 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,14 +19,16 @@ export interface PushInLayer { element: HTMLElement; index: number; originalScale: number; - ref: { - inpoints: number[]; - outpoints: number[]; - speed: number; - }; - params: { - inpoint: number; - outpoint: number; - speed: number; - }; +} + +export interface LayerRef { + inpoints: number[]; + outpoints: number[]; + speed: number; +} + +export interface LayerParams { + inpoint: number; + outpoint: number; + speed: number; } From f1a25c7573920c1b65443ee09f5ac3352f4515a5 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sat, 16 Apr 2022 20:27:31 -0500 Subject: [PATCH 02/32] #69: WIP - move code into separate classes --- src/pushinScene.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pushinScene.ts b/src/pushinScene.ts index 097b1e7..c20c8f8 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -13,7 +13,11 @@ export class PushInScene { private container: HTMLElement; private readonly cleanupFns: VoidFunction[] = []; - constructor(private parent: HTMLElement, private options?: SceneOptions, private layerOptions?: LayerOptions ) { + constructor( + private parent: HTMLElement, + private options?: SceneOptions, + private layerOptions?: LayerOptions + ) { const container = this.parent.querySelector('.pushin-scene'); if (container) { From f1c711d9f4da1fc8569d9c43bdcfc01b8970d7bc Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 17 Apr 2022 13:52:56 -0500 Subject: [PATCH 03/32] #69: WIP - move more code into separate classes and fix errors --- src/pushin.ts | 324 ++---------------------------------- src/pushinLayer.ts | 97 +++-------- src/pushinScene.ts | 378 +++++------------------------------------- src/types.ts | 3 + test/addScene.spec.ts | 48 ------ 5 files changed, 76 insertions(+), 774 deletions(-) delete mode 100644 test/addScene.spec.ts diff --git a/src/pushin.ts b/src/pushin.ts index f2e42c6..b32fed9 100644 --- a/src/pushin.ts +++ b/src/pushin.ts @@ -1,10 +1,5 @@ -import { - DEFAULT_SPEED, - PUSH_IN_TO_DATA_ATTRIBUTE, - PUSH_IN_FROM_DATA_ATTRIBUTE, - PUSH_IN_SPEED_DATA_ATTRIBUTE, - PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE, -} from './constants'; +import { PushInScene } from './pushinScene'; + import { PushInLayer, PushInOptions, @@ -19,7 +14,7 @@ import { * bind events to begin interacting with dom. */ export class PushIn { - private scene!: HTMLElement; + private scene!: PushInScene; private layerOptions: LayerOptions[]; private sceneOptions: SceneOptions; @@ -31,10 +26,6 @@ export class PushIn { private readonly layers: PushInLayer[] = []; private readonly debug: boolean; - private speedDelta = 100; - private transitionLength = 200; - private layerDepth = 1000; - private lastAnimationFrameId = -1; private readonly cleanupFns: VoidFunction[] = []; @@ -48,13 +39,19 @@ export class PushIn { * Initialize the object to start everything up. */ start(): void { + if (this.debug) { + this.showDebugger(); + } + if (this.container) { - this.addScene(); + this.scene = new PushInScene( + this.container, + this.sceneOptions, + this.layerOptions + ); this.scrollPos = window.pageYOffset; - this.setBreakpoints(); - this.getLayers(); this.setScrollLength(); this.bindEvents(); @@ -66,10 +63,6 @@ export class PushIn { 'No container element provided to pushIn.js. Effect will not be applied.' ); } - - if (this.debug) { - this.showDebugger(); - } } /** @@ -83,162 +76,6 @@ export class PushIn { } } - /** - * Get the "scene" element from the DOM. - * If it doesn't exist, make one. - */ - private addScene(): void { - const scene = this.container.querySelector('.pushin-scene'); - - if (scene) { - this.scene = scene; - } else { - this.scene = document.createElement('div'); - this.scene.classList.add('pushin-scene'); - - this.scene.innerHTML = this.container.innerHTML; - this.container.innerHTML = ''; - this.container.appendChild(this.scene); - // We register the cleanup function only for the manually created scene. - this.cleanupFns.push(() => this.container.removeChild(this.scene)); - } - } - - /** - * Set breakpoints for responsive design settings. - */ - private setBreakpoints(): void { - if (this.sceneOptions.breakpoints.length === 0) { - this.sceneOptions.breakpoints = [768, 1440, 1920]; - } - - if (this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { - this.sceneOptions.breakpoints = this.scene.dataset[ - PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE - ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); - } - - // Always include break point 0 for anything under first breakpoint - this.sceneOptions.breakpoints.unshift(0); - } - - /** - * Find all layers on the page and store them with their parameters - */ - private getLayers(): void { - const layers = Array.from( - this.container.getElementsByClassName('pushin-layer') - ); - - for (let index = 0; index < layers.length; index++) { - const element = layers[index]; - const inpoints = this.getInpoints(element, index); - const outpoints = this.getOutpoints(element, inpoints[0], index); - const speed = this.getSpeed(element, index); - - const layer: PushInLayer = { - element, - index, - originalScale: this.getElementScaleX(element), - ref: { inpoints, outpoints, speed }, - params: { - inpoint: this.getInpoint(inpoints), - outpoint: this.getOutpoint(outpoints), - speed, - }, - }; - - this.layers.push(layer); - this.setZIndex(layer, layers.length); - } - } - - /** - * Get all inpoints for the layer. - */ - private getInpoints(element: HTMLElement, index: number): number[] { - const { top } = this.scene.getBoundingClientRect(); - - let inpoints = [top]; - if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map( - inpoint => parseInt(inpoint.trim(), 10) - ); - } else if (this.layerOptions[index]?.inpoints) { - inpoints = this.layerOptions[index].inpoints; - } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - // Custom inpoint - inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split( - ',' - ).map(inpoint => parseInt(inpoint.trim(), 10)); - } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) { - inpoints = this.sceneOptions.inpoints; - } else if (index > 0) { - // Set default for middle layers if none provided - const { outpoint } = this.layers[index - 1].params; - inpoints = [outpoint - this.speedDelta]; - } - - return inpoints; - } - - /** - * Get all outpoints for the layer. - */ - private getOutpoints( - element: HTMLElement, - inpoint: number, - index: number - ): number[] { - let outpoints = [inpoint + this.layerDepth]; - - if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { - const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(','); - outpoints = values.map(value => parseInt(value.trim(), 10)); - } else if (this.layerOptions[index]?.outpoints) { - outpoints = this.layerOptions[index].outpoints; - } - - return outpoints; - } - - /** - * Get the push-in speed for the layer. - */ - private getSpeed(element: HTMLElement, index: number): number { - let speed: number | null = null; - - if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { - speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10); - if (Number.isNaN(speed)) { - speed = DEFAULT_SPEED; - } - } else if (this.layerOptions[index]?.speed) { - speed = this.layerOptions[index].speed; - } - - return speed || DEFAULT_SPEED; - } - - /** - * Get the array index of the current window breakpoint. - */ - private getBreakpointIndex(): number { - const searchIndex = this.sceneOptions.breakpoints - .reverse() - .findIndex(bp => bp <= window.innerWidth); - return searchIndex === -1 - ? 0 - : this.sceneOptions.breakpoints.length - 1 - searchIndex; - } - - /** - * Set the z-index of each layer so they overlap correctly. - */ - private setZIndex(layer: PushInLayer, total: number): void { - layer.element.style.zIndex = (total - layer.index).toString(); - } - /** * Bind event listeners to watch for page load and user interaction. */ @@ -300,42 +137,6 @@ export class PushIn { this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); } - /** - * Reset all the layer parameters. - * - * This is used if the window is resized - * and things need to be recalculated. - */ - private resetLayerParams(): void { - this.layers.forEach(layer => { - layer.params = { - inpoint: this.getInpoint(layer.ref.inpoints), - outpoint: this.getOutpoint(layer.ref.outpoints), - speed: layer.ref.speed, - }; - }); - } - - /** - * Get the initial scale of the element at time of DOM load. - */ - private getElementScaleX(element: HTMLElement): number { - const transform = window - .getComputedStyle(element) - .getPropertyValue('transform'); - - let scaleX = 1; - if (transform && transform !== 'none') { - const match = transform.match(/[matrix|scale]\(([\d,.\s]+)/); - if (match && match[1]) { - const matrix = match[1].split(', '); - scaleX = parseFloat(matrix[0]); - } - } - - return scaleX; - } - /** * Animation effect, mimicking a camera dolly on the webpage. */ @@ -351,101 +152,7 @@ export class PushIn { * Show or hide layers and set their scale, depending on if active. */ private toggleLayers(): void { - this.layers.forEach(layer => this.setLayerStyle(layer)); - } - - /** - * Whether or not a layer should currently be zooming. - */ - private isActive(layer: PushInLayer): boolean { - const { inpoint } = layer.params; - const { outpoint } = layer.params; - return this.scrollPos >= inpoint && this.scrollPos <= outpoint; - } - - /** - * Get the current inpoint for a layer, - * depending on window breakpoint. - */ - private getInpoint(inpoints: number[]): number { - return inpoints[this.getBreakpointIndex()] || inpoints[0]; - } - - /** - * Get the current outpoint for a layer, - * depending on window breakpoint. - */ - private getOutpoint(outpoints: number[]): number { - return outpoints[this.getBreakpointIndex()] || outpoints[0]; - } - - /** - * Get the scaleX value for the layer. - */ - private getScaleValue(layer: PushInLayer): number { - const distance = this.scrollPos - layer.params.inpoint; - const speed = Math.min(layer.params.speed, 100) / 100; - const delta = (distance * speed) / 100; - - return Math.max(layer.originalScale + delta, 0); - } - - /** - * Set element scale. - */ - private setScale({ style }: HTMLElement, value: number): void { - const scaleString = `scale(${value})`; - style.webkitTransform = scaleString; - (style as unknown as { mozTransform: string }).mozTransform = scaleString; - (style as unknown as { msTransform: string }).msTransform = scaleString; - (style as unknown as { oTransform: string }).oTransform = scaleString; - style.transform = scaleString; - } - - /** - * Set CSS styles to control the effect on each layer. - * - * This will control the scale and opacity of the layer - * as the user scrolls. - */ - private setLayerStyle(layer: PushInLayer): void { - let opacity = 0; - const isFirst = layer.index === 0; - const isLast = layer.index + 1 === this.layers.length; - const { inpoint } = layer.params; - const { outpoint } = layer.params; - - if (isFirst && this.scrollPos < inpoint) { - opacity = 1; - } else if (isLast && this.scrollPos > outpoint) { - opacity = 1; - } else if (this.isActive(layer)) { - this.setScale(layer.element, this.getScaleValue(layer)); - - let inpointDistance = - Math.max(Math.min(this.scrollPos - inpoint, this.transitionLength), 0) / - this.transitionLength; - - // Set opacity to 1 if its the first layer and it is active (no fading in here) - if (isFirst) { - inpointDistance = 1; - } - - let outpointDistance = - Math.max( - Math.min(outpoint - this.scrollPos, this.transitionLength), - 0 - ) / this.transitionLength; - - // Set opacity to 1 if its the last layer and it is active (no fading out) - if (isLast) { - outpointDistance = 1; - } - - opacity = Math.min(inpointDistance, outpointDistance); - } - - layer.element.style.opacity = opacity.toString(); + this.layers.forEach(layer => layer.setLayerStyle()); } /** @@ -463,9 +170,10 @@ export class PushIn { '' ); - const transitions = (this.layers.length - 1) * this.speedDelta; + const transitions = (this.layers.length - 1) * this.scene.speedDelta; const scrollLength = - this.layers.length * (this.layerDepth + this.transitionLength); + this.layers.length * + (this.scene.layerDepth + this.scene.transitionLength); this.container.style.height = `${Math.max( parseFloat(containerHeight), diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts index 6463f21..adb1f9d 100644 --- a/src/pushinLayer.ts +++ b/src/pushinLayer.ts @@ -4,6 +4,7 @@ import { PUSH_IN_FROM_DATA_ATTRIBUTE, PUSH_IN_SPEED_DATA_ATTRIBUTE, } from './constants'; +import { PushInScene } from './pushinScene'; import { LayerOptions, LayerRef, LayerParams } from './types'; @@ -15,7 +16,7 @@ export class PushInLayer { constructor( private element: HTMLElement, private index: number, - private scene: HTMLElement, + private scene: PushInScene, private options: LayerOptions | null ) { const inpoints = this.getInpoints(this.element, this.index); @@ -36,25 +37,18 @@ export class PushInLayer { * Get all inpoints for the layer. */ private getInpoints(element: HTMLElement, index: number): number[] { - const { top } = this.scene.getBoundingClientRect(); - - let inpoints = [top]; + let inpoints = [this.scene.getTop()]; if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map( inpoint => parseInt(inpoint.trim(), 10) ); } else if (this.options?.inpoints) { inpoints = this.options.inpoints; - } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - // Custom inpoint - inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split( - ',' - ).map(inpoint => parseInt(inpoint.trim(), 10)); - } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) { - inpoints = this.sceneOptions.inpoints; + } else if (index === 0) { + inpoints = this.scene.getInpoints(); } else if (index > 0) { // Set default for middle layers if none provided - const { outpoint } = this.layers[index - 1].params; + const { outpoint } = this.scene.layers[index - 1].params; inpoints = [outpoint - this.speedDelta]; } @@ -110,8 +104,8 @@ export class PushInLayer { /** * Set the z-index of each layer so they overlap correctly. */ - setZIndex(layer: PushInLayer, total: number): void { - layer.element.style.zIndex = (total - layer.index).toString(); + setZIndex(total: number): void { + this.element.style.zIndex = (total - this.index).toString(); } /** @@ -220,23 +214,25 @@ export class PushInLayer { * This will control the scale and opacity of the layer * as the user scrolls. */ - private setLayerStyle(layer: PushInLayer): void { + setLayerStyle(): void { let opacity = 0; - const isFirst = layer.index === 0; - const isLast = layer.index + 1 === this.layers.length; - const { inpoint } = layer.params; - const { outpoint } = layer.params; + const isFirst = this.index === 0; + const isLast = this.index + 1 === this.scene.layers.length; + const { inpoint } = this.params; + const { outpoint } = this.params; if (isFirst && this.scrollPos < inpoint) { opacity = 1; } else if (isLast && this.scrollPos > outpoint) { opacity = 1; - } else if (this.isActive(layer)) { - this.setScale(layer.element, this.getScaleValue(layer)); + } else if (this.isActive(this)) { + this.setScale(this.element, this.getScaleValue(this)); let inpointDistance = - Math.max(Math.min(this.scrollPos - inpoint, this.transitionLength), 0) / - this.transitionLength; + Math.max( + Math.min(this.scrollPos - inpoint, this.scene.transitionLength), + 0 + ) / this.scene.transitionLength; // Set opacity to 1 if its the first layer and it is active (no fading in here) if (isFirst) { @@ -257,59 +253,6 @@ export class PushInLayer { opacity = Math.min(inpointDistance, outpointDistance); } - layer.element.style.opacity = opacity.toString(); - } - - /** - * Set the default container height based on a few factors: - * 1. Number of layers present - * 2. The transition length between layers - * 3. The length of scrolling time during each layer - * - * If this calculation is smaller than the container's current height, - * the current height will be used instead. - */ - private setScrollLength(): void { - const containerHeight = getComputedStyle(this.container).height.replace( - 'px', - '' - ); - - const transitions = (this.layers.length - 1) * this.speedDelta; - const scrollLength = - this.layers.length * (this.layerDepth + this.transitionLength); - - this.container.style.height = `${Math.max( - parseFloat(containerHeight), - scrollLength - transitions - )}px`; - } - - /** - * Show a debugging tool appended to the frontend of the page. - * Can be used to determine best "pushin-from" and "pushin-to" values. - */ - private showDebugger(): void { - const scrollCounter = document.createElement('div'); - scrollCounter.classList.add('pushin-debug'); - - const scrollTitle = document.createElement('p'); - scrollTitle.innerText = 'Pushin.js Debugger'; - scrollTitle.classList.add('pushin-debug__title'); - - const debuggerContent = document.createElement('div'); - debuggerContent.classList.add('pushin-debug__content'); - debuggerContent.innerText = `Scroll position: ${window.pageYOffset}px`; - - scrollCounter.appendChild(scrollTitle); - scrollCounter.appendChild(debuggerContent); - - document.body.appendChild(scrollCounter); - - window.addEventListener('scroll', () => { - debuggerContent.innerText = `Scroll position: ${Math.round( - window.pageYOffset - )}px`; - }); + this.element.style.opacity = opacity.toString(); } } diff --git a/src/pushinScene.ts b/src/pushinScene.ts index c20c8f8..952a82b 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -12,11 +12,15 @@ import { SceneOptions, LayerOptions } from './types'; export class PushInScene { private container: HTMLElement; private readonly cleanupFns: VoidFunction[] = []; + public layers: PushInLayer[]; + public speedDelta: number; + public transitionLength: number; + public layerDepth: number; constructor( private parent: HTMLElement, private options?: SceneOptions, - private layerOptions?: LayerOptions + private layerOptions?: LayerOptions[] ) { const container = this.parent.querySelector('.pushin-scene'); @@ -29,9 +33,18 @@ export class PushInScene { this.container.innerHTML = this.parent.innerHTML; this.parent.innerHTML = ''; this.parent.appendChild(this.container); - this.cleanupFns.push(() => this.container.removeChild(this.container)); + this.cleanupFns.push(() => { + this.parent.innerHTML = this.container.innerHTML; + }); } + this.speedDelta = options?.speedDelta || 100; + this.layerDepth = options?.layerDepth || 1000; + this.transitionLength = options?.transitionLength || 200; + + this.layers = []; + + this.setBreakpoints(); this.getLayers(); } @@ -63,363 +76,46 @@ export class PushInScene { for (let index = 0; index < layers.length; index++) { const element = layers[index]; - const layerOptions = this.layerOptions ?? {}; - const layer = new PushInLayer( - element, - index, - this.container, - layerOptions - ); - this.layers.push(layer); - this.setZIndex(layer, layers.length); - } - } - - /** - * Get all inpoints for the layer. - */ - private getInpoints(element: HTMLElement, index: number): number[] { - const { top } = this.scene.getBoundingClientRect(); - - let inpoints = [top]; - if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map( - inpoint => parseInt(inpoint.trim(), 10) - ); - } else if (this.layerOptions[index]?.inpoints) { - inpoints = this.layerOptions[index].inpoints; - } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - // Custom inpoint - inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split( - ',' - ).map(inpoint => parseInt(inpoint.trim(), 10)); - } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) { - inpoints = this.sceneOptions.inpoints; - } else if (index > 0) { - // Set default for middle layers if none provided - const { outpoint } = this.layers[index - 1].params; - inpoints = [outpoint - this.speedDelta]; - } - - return inpoints; - } - - /** - * Get all outpoints for the layer. - */ - private getOutpoints( - element: HTMLElement, - inpoint: number, - index: number - ): number[] { - let outpoints = [inpoint + this.layerDepth]; - - if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { - const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(','); - outpoints = values.map(value => parseInt(value.trim(), 10)); - } else if (this.layerOptions[index]?.outpoints) { - outpoints = this.layerOptions[index].outpoints; - } - - return outpoints; - } + let options = {}; + if (this.layerOptions && this.layerOptions.length > index) { + options = this!.layerOptions[index]; + } - /** - * Get the push-in speed for the layer. - */ - private getSpeed(element: HTMLElement, index: number): number { - let speed: number | null = null; + const layer = new PushInLayer(element, index, this, options); + this.layers.push(layer); - if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { - speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10); - if (Number.isNaN(speed)) { - speed = DEFAULT_SPEED; - } - } else if (this.layerOptions[index]?.speed) { - speed = this.layerOptions[index].speed; + layer.setZIndex(layers.length); } - - return speed || DEFAULT_SPEED; } /** * Get the array index of the current window breakpoint. */ private getBreakpointIndex(): number { - const searchIndex = this.sceneOptions.breakpoints - .reverse() - .findIndex(bp => bp <= window.innerWidth); + const searchIndex = this.options!.breakpoints.reverse().findIndex( + bp => bp <= window.innerWidth + ); return searchIndex === -1 ? 0 - : this.sceneOptions.breakpoints.length - 1 - searchIndex; + : this.options!.breakpoints.length - 1 - searchIndex; } - /** - * Set the z-index of each layer so they overlap correctly. - */ - private setZIndex(layer: PushInLayer, total: number): void { - layer.element.style.zIndex = (total - layer.index).toString(); + getTop() { + return this.container.getBoundingClientRect().top; } - /** - * Bind event listeners to watch for page load and user interaction. - */ - private bindEvents(): void { - const onScroll = () => { - this.scrollPos = window.pageYOffset; - this.dolly(); - }; - window.addEventListener('scroll', onScroll); - this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); - - const onTouchstart = (event: TouchEvent) => { - this.touchStart = event.changedTouches[0].screenY; - }; - window.addEventListener('touchstart', onTouchstart); - this.cleanupFns.push(() => - window.removeEventListener('touchstart', onTouchstart) - ); - - const onTouchmove = (event: TouchEvent) => { - event.preventDefault(); + getInpoints(): number[] { + let inpoints = []; - const touchMove = event.changedTouches[0].screenY; - this.scrollPos = Math.max( - this.scrollEnd! + this.touchStart! - touchMove, - 0 + if (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + const pushInFrom = ( + this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE] ); - this.scrollPos = Math.min( - this.scrollPos, - this.pageHeight! - window.innerHeight - ); - - this.dolly(); - }; - window.addEventListener('touchmove', onTouchmove); - this.cleanupFns.push(() => - window.removeEventListener('touchmove', onTouchmove) - ); - - const onTouchend = () => { - this.scrollEnd = this.scrollPos; - }; - window.addEventListener('touchend', onTouchend); - this.cleanupFns.push(() => - window.removeEventListener('touchend', onTouchend) - ); - - let resizeTimeout: number; - const onResize = () => { - clearTimeout(resizeTimeout); - - resizeTimeout = window.setTimeout(() => { - this.resetLayerParams(); - this.setScrollLength(); - this.toggleLayers(); - }, 300); - }; - window.addEventListener('resize', onResize); - this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); - } - - /** - * Reset all the layer parameters. - * - * This is used if the window is resized - * and things need to be recalculated. - */ - private resetLayerParams(): void { - this.layers.forEach(layer => { - layer.params = { - inpoint: this.getInpoint(layer.ref.inpoints), - outpoint: this.getOutpoint(layer.ref.outpoints), - speed: layer.ref.speed, - }; - }); - } - - /** - * Get the initial scale of the element at time of DOM load. - */ - private getElementScaleX(element: HTMLElement): number { - const transform = window - .getComputedStyle(element) - .getPropertyValue('transform'); - - let scaleX = 1; - if (transform && transform !== 'none') { - const match = transform.match(/[matrix|scale]\(([\d,.\s]+)/); - if (match && match[1]) { - const matrix = match[1].split(', '); - scaleX = parseFloat(matrix[0]); - } - } - - return scaleX; - } - - /** - * Animation effect, mimicking a camera dolly on the webpage. - */ - private dolly(): void { - cancelAnimationFrame(this.lastAnimationFrameId); - - this.lastAnimationFrameId = requestAnimationFrame(() => { - this.toggleLayers(); - }); - } - - /** - * Show or hide layers and set their scale, depending on if active. - */ - private toggleLayers(): void { - this.layers.forEach(layer => this.setLayerStyle(layer)); - } - - /** - * Whether or not a layer should currently be zooming. - */ - private isActive(layer: PushInLayer): boolean { - const { inpoint } = layer.params; - const { outpoint } = layer.params; - return this.scrollPos >= inpoint && this.scrollPos <= outpoint; - } - - /** - * Get the current inpoint for a layer, - * depending on window breakpoint. - */ - private getInpoint(inpoints: number[]): number { - return inpoints[this.getBreakpointIndex()] || inpoints[0]; - } - - /** - * Get the current outpoint for a layer, - * depending on window breakpoint. - */ - private getOutpoint(outpoints: number[]): number { - return outpoints[this.getBreakpointIndex()] || outpoints[0]; - } - - /** - * Get the scaleX value for the layer. - */ - private getScaleValue(layer: PushInLayer): number { - const distance = this.scrollPos - layer.params.inpoint; - const speed = Math.min(layer.params.speed, 100) / 100; - const delta = (distance * speed) / 100; - - return Math.max(layer.originalScale + delta, 0); - } - - /** - * Set element scale. - */ - private setScale({ style }: HTMLElement, value: number): void { - const scaleString = `scale(${value})`; - style.webkitTransform = scaleString; - (style as unknown as { mozTransform: string }).mozTransform = scaleString; - (style as unknown as { msTransform: string }).msTransform = scaleString; - (style as unknown as { oTransform: string }).oTransform = scaleString; - style.transform = scaleString; - } - - /** - * Set CSS styles to control the effect on each layer. - * - * This will control the scale and opacity of the layer - * as the user scrolls. - */ - private setLayerStyle(layer: PushInLayer): void { - let opacity = 0; - const isFirst = layer.index === 0; - const isLast = layer.index + 1 === this.layers.length; - const { inpoint } = layer.params; - const { outpoint } = layer.params; - - if (isFirst && this.scrollPos < inpoint) { - opacity = 1; - } else if (isLast && this.scrollPos > outpoint) { - opacity = 1; - } else if (this.isActive(layer)) { - this.setScale(layer.element, this.getScaleValue(layer)); - - let inpointDistance = - Math.max(Math.min(this.scrollPos - inpoint, this.transitionLength), 0) / - this.transitionLength; - - // Set opacity to 1 if its the first layer and it is active (no fading in here) - if (isFirst) { - inpointDistance = 1; - } - - let outpointDistance = - Math.max( - Math.min(outpoint - this.scrollPos, this.transitionLength), - 0 - ) / this.transitionLength; - - // Set opacity to 1 if its the last layer and it is active (no fading out) - if (isLast) { - outpointDistance = 1; - } - - opacity = Math.min(inpointDistance, outpointDistance); + inpoints.push(parseInt(pushInFrom, 10)); + } else if (this.options && this.options?.inpoints?.length > 0) { + inpoints = this.options.inpoints; } - layer.element.style.opacity = opacity.toString(); - } - - /** - * Set the default container height based on a few factors: - * 1. Number of layers present - * 2. The transition length between layers - * 3. The length of scrolling time during each layer - * - * If this calculation is smaller than the container's current height, - * the current height will be used instead. - */ - private setScrollLength(): void { - const containerHeight = getComputedStyle(this.container).height.replace( - 'px', - '' - ); - - const transitions = (this.layers.length - 1) * this.speedDelta; - const scrollLength = - this.layers.length * (this.layerDepth + this.transitionLength); - - this.container.style.height = `${Math.max( - parseFloat(containerHeight), - scrollLength - transitions - )}px`; - } - - /** - * Show a debugging tool appended to the frontend of the page. - * Can be used to determine best "pushin-from" and "pushin-to" values. - */ - private showDebugger(): void { - const scrollCounter = document.createElement('div'); - scrollCounter.classList.add('pushin-debug'); - - const scrollTitle = document.createElement('p'); - scrollTitle.innerText = 'Pushin.js Debugger'; - scrollTitle.classList.add('pushin-debug__title'); - - const debuggerContent = document.createElement('div'); - debuggerContent.classList.add('pushin-debug__content'); - debuggerContent.innerText = `Scroll position: ${window.pageYOffset}px`; - - scrollCounter.appendChild(scrollTitle); - scrollCounter.appendChild(debuggerContent); - - document.body.appendChild(scrollCounter); - - window.addEventListener('scroll', () => { - debuggerContent.innerText = `Scroll position: ${Math.round( - window.pageYOffset - )}px`; - }); + return inpoints; } } diff --git a/src/types.ts b/src/types.ts index 3011113..acb8e6f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,6 +5,9 @@ export interface LayerOptions { } export interface SceneOptions { + speedDelta?: number; + layerDepth?: number; + transitionLength?: number; breakpoints: number[]; inpoints: number[]; } diff --git a/test/addScene.spec.ts b/test/addScene.spec.ts deleted file mode 100644 index c8f20ad..0000000 --- a/test/addScene.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -require('chai').should(); - -let jsdom = require('jsdom'); -let JSDOM = jsdom.JSDOM; - -import { PushIn } from '../src/pushin'; - -describe('addScene', function () { - this.beforeEach(function () { - this.textContent = 'FooBar'; - var dom = new JSDOM(` - - -
-
${this.textContent}
-
- - `); - - global.window = dom.window; - global.document = window.document; - - const container = document.querySelector('.pushin'); - this.pushIn = new PushIn(container); - }); - - it('Should assign existing .pushin-scene element to the scene property', function () { - this.pushIn.addScene(); - const result = this.pushIn.scene.textContent; - result.should.equal(this.textContent); - }); - - it("Should create new .pushin-scene element if it doesn't yet exist", function () { - document.querySelector('.pushin-scene').remove(); - this.pushIn.addScene(); - const result = this.pushIn.scene.classList.contains('pushin-scene'); - result.should.be.true; - }); - - it('Should move any inner HTML into the new scene element as children', function () { - const innerHTML = 'FooBar'; - document.querySelector('.pushin-scene').remove(); - document.querySelector('.pushin').innerHTML = innerHTML; - this.pushIn.addScene(); - const result = this.pushIn.scene.innerHTML; - result.should.equal(innerHTML); - }); -}); From 4ab7a389bdbdcacce9139f7461211b5841b116da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:19:18 +0000 Subject: [PATCH 04/32] Bump @typescript-eslint/eslint-plugin from 5.19.0 to 5.20.0 Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.20.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 429 +++++++++++++++++++--------------------------- 1 file changed, 179 insertions(+), 250 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..5dacac7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2855,14 +2855,14 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.20.0.tgz", + "integrity": "sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/type-utils": "5.20.0", + "@typescript-eslint/utils": "5.20.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -2887,53 +2887,6 @@ } } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { "version": "7.3.6", "dev": true, @@ -3096,15 +3049,14 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz", + "integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==", "dev": true, "dependencies": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3112,28 +3064,17 @@ "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } } }, - "node_modules/@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", + "node_modules/@typescript-eslint/type-utils": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.20.0.tgz", + "integrity": "sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==", "dev": true, "dependencies": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "@typescript-eslint/utils": "5.20.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3143,30 +3084,18 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "eslint": "*" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", + "node_modules/@typescript-eslint/types": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz", + "integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3176,14 +3105,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz", + "integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -3203,46 +3132,7 @@ } } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/globby": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", @@ -3262,7 +3152,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", @@ -3274,7 +3164,7 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/utils/node_modules/semver": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", @@ -3289,6 +3179,69 @@ "node": ">=10" } }, + "node_modules/@typescript-eslint/utils": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.20.0.tgz", + "integrity": "sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/typescript-estree": "5.20.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz", + "integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.20.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -14926,14 +14879,14 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.20.0.tgz", + "integrity": "sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/type-utils": "5.20.0", + "@typescript-eslint/utils": "5.20.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -14942,32 +14895,6 @@ "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, "semver": { "version": "7.3.6", "dev": true, @@ -15064,88 +14991,48 @@ } } }, + "@typescript-eslint/scope-manager": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz", + "integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0" + } + }, "@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.20.0.tgz", + "integrity": "sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==", "dev": true, "requires": { - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/utils": "5.20.0", "debug": "^4.3.2", "tsutils": "^3.21.0" } }, - "@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", + "@typescript-eslint/types": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz", + "integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz", + "integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==", "dev": true, "requires": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -15180,6 +15067,48 @@ } } }, + "@typescript-eslint/utils": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.20.0.tgz", + "integrity": "sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/typescript-estree": "5.20.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz", + "integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.20.0", + "eslint-visitor-keys": "^3.0.0" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "dev": true, From 18d3b45f3ce174519608a42bc13778c5752f5b9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:19:30 +0000 Subject: [PATCH 05/32] Bump @typescript-eslint/parser from 5.19.0 to 5.20.0 Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.20.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 250 +++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..199cfbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2949,14 +2949,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.20.0.tgz", + "integrity": "sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/typescript-estree": "5.20.0", "debug": "^4.3.2" }, "engines": { @@ -2975,14 +2975,14 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz", + "integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2992,10 +2992,36 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "node_modules/@typescript-eslint/type-utils": { "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", + "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "5.19.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz", + "integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3005,14 +3031,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz", + "integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -3032,24 +3058,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/globby": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", @@ -3069,7 +3078,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@typescript-eslint/parser/node_modules/lru-cache": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", @@ -3081,7 +3090,7 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/parser/node_modules/semver": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", @@ -3096,32 +3105,6 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "dependencies": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, "node_modules/@typescript-eslint/utils": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", @@ -3289,6 +3272,23 @@ "node": ">=10" } }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz", + "integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.20.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -14978,58 +14978,59 @@ } }, "@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.20.0.tgz", + "integrity": "sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", + "@typescript-eslint/scope-manager": "5.20.0", + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/typescript-estree": "5.20.0", "debug": "^4.3.2" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz", + "integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", + "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "5.19.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz", + "integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz", + "integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.20.0", + "@typescript-eslint/visitor-keys": "5.20.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -15064,17 +15065,6 @@ } } }, - "@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "requires": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - } - }, "@typescript-eslint/utils": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", @@ -15180,6 +15170,16 @@ } } }, + "@typescript-eslint/visitor-keys": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz", + "integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.20.0", + "eslint-visitor-keys": "^3.0.0" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "dev": true, From 2039fa7e4e7dc86da7553e3f3a5ed7626cf78eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:19:52 +0000 Subject: [PATCH 06/32] Bump eslint from 8.13.0 to 8.14.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.13.0 to 8.14.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.13.0...v8.14.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 69 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..0c67838 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1583,9 +1583,10 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.2.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.2.tgz", + "integrity": "sha512-lTVWHs7O2hjBFZunXTZYnYqtB9GakA1lnxIf+gKq2nY5gxkkNi/lQvveW6t8gFdOHTg6nG50Xs95PrLqVpcaLg==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -1603,8 +1604,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/globals": { "version": "13.13.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", + "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", "dev": true, - "license": "MIT", "dependencies": { "type-fest": "^0.20.2" }, @@ -1617,8 +1619,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, - "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, @@ -3521,8 +3524,9 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, - "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -3681,8 +3685,9 @@ }, "node_modules/argparse": { "version": "2.0.1", - "dev": true, - "license": "Python-2.0" + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "node_modules/array-flatten": { "version": "2.1.2", @@ -5280,11 +5285,12 @@ } }, "node_modules/eslint": { - "version": "8.13.0", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.14.0.tgz", + "integrity": "sha512-3/CE4aJX7LNEiE3i6FeodHmI/38GZtWCsAtsymScmzYapx8q1nVVb+eLcLSzATmCPXw5pT4TqVs1E0OmxAd9tw==", "dev": true, - "license": "MIT", "dependencies": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.2", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -5613,8 +5619,9 @@ }, "node_modules/espree": { "version": "9.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", + "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "acorn": "^8.7.0", "acorn-jsx": "^5.3.1", @@ -6523,8 +6530,9 @@ }, "node_modules/import-fresh": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, - "license": "MIT", "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -9035,8 +9043,9 @@ }, "node_modules/js-yaml": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, @@ -10044,8 +10053,9 @@ }, "node_modules/parent-module": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, - "license": "MIT", "dependencies": { "callsites": "^3.0.0" }, @@ -10833,8 +10843,9 @@ }, "node_modules/resolve-from": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -13947,7 +13958,9 @@ "dev": true }, "@eslint/eslintrc": { - "version": "1.2.1", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.2.tgz", + "integrity": "sha512-lTVWHs7O2hjBFZunXTZYnYqtB9GakA1lnxIf+gKq2nY5gxkkNi/lQvveW6t8gFdOHTg6nG50Xs95PrLqVpcaLg==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -13963,6 +13976,8 @@ "dependencies": { "globals": { "version": "13.13.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz", + "integrity": "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -13970,6 +13985,8 @@ }, "type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true } } @@ -15358,6 +15375,8 @@ }, "acorn-jsx": { "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "requires": {} }, @@ -15456,6 +15475,8 @@ }, "argparse": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, "array-flatten": { @@ -16532,10 +16553,12 @@ } }, "eslint": { - "version": "8.13.0", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.14.0.tgz", + "integrity": "sha512-3/CE4aJX7LNEiE3i6FeodHmI/38GZtWCsAtsymScmzYapx8q1nVVb+eLcLSzATmCPXw5pT4TqVs1E0OmxAd9tw==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.2", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -16748,6 +16771,8 @@ }, "espree": { "version": "9.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", + "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", "dev": true, "requires": { "acorn": "^8.7.0", @@ -17335,6 +17360,8 @@ }, "import-fresh": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -19111,6 +19138,8 @@ }, "js-yaml": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -19760,6 +19789,8 @@ }, "parent-module": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "requires": { "callsites": "^3.0.0" @@ -20286,6 +20317,8 @@ }, "resolve-from": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "resolve.exports": { From ffb18807f7cf8351fb6353361ca18e42845ceb56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:20:05 +0000 Subject: [PATCH 07/32] Bump lint-staged from 12.3.8 to 12.4.0 Bumps [lint-staged](https://github.com/okonet/lint-staged) from 12.3.8 to 12.4.0. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v12.3.8...v12.4.0) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..3511972 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9202,9 +9202,9 @@ "dev": true }, "node_modules/lint-staged": { - "version": "12.3.8", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.8.tgz", - "integrity": "sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==", + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.0.tgz", + "integrity": "sha512-3X7MR0h9b7qf4iXf/1n7RlVAx+EzpAZXoCEMhVSpaBlgKDfH2ewf+QUm7BddFyq29v4dgPP+8+uYpWuSWx035A==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", @@ -19225,9 +19225,9 @@ "dev": true }, "lint-staged": { - "version": "12.3.8", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.8.tgz", - "integrity": "sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==", + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.0.tgz", + "integrity": "sha512-3X7MR0h9b7qf4iXf/1n7RlVAx+EzpAZXoCEMhVSpaBlgKDfH2ewf+QUm7BddFyq29v4dgPP+8+uYpWuSWx035A==", "dev": true, "requires": { "cli-truncate": "^3.1.0", From 3f54a36eb31cb251454b557f7280afa09d04f69c Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Wed, 27 Apr 2022 21:09:51 -0500 Subject: [PATCH 08/32] #69: Refactor and move code into separate classes --- src/pushin.ts | 71 +++++++++++++++++++--------------------------- src/pushinLayer.ts | 70 ++++++++++++++++----------------------------- src/pushinScene.ts | 58 ++++++++++++++++++------------------- src/types.ts | 1 + 4 files changed, 83 insertions(+), 117 deletions(-) diff --git a/src/pushin.ts b/src/pushin.ts index 99c7771..c2ff3af 100644 --- a/src/pushin.ts +++ b/src/pushin.ts @@ -1,11 +1,7 @@ import { PushInScene } from './pushinScene'; +import { PushInLayer } from './pushinLayer'; -import { - PushInLayer, - PushInOptions, - LayerOptions, - SceneOptions, -} from './types'; +import { PushInOptions, SceneOptions } from './types'; /** * PushIn object @@ -16,13 +12,9 @@ import { export class PushIn { private scene!: PushInScene; private pushinDebug?: HTMLElement; - private layerOptions: LayerOptions[]; - private sceneOptions: SceneOptions; + public sceneOptions: SceneOptions; - private scrollY = 0; - private scrollEnd: number | null = null; - private touchStart: number | null = null; - private pageHeight: number | null = null; + public scrollY = 0; private readonly layers: PushInLayer[] = []; private readonly debug: boolean; @@ -30,32 +22,30 @@ export class PushIn { private lastAnimationFrameId = -1; private readonly cleanupFns: VoidFunction[] = []; - constructor(private container: HTMLElement, options?: PushInOptions) { + constructor(public container: HTMLElement, options?: PushInOptions) { this.debug = options?.debug ?? false; - this.layerOptions = options?.layers ?? []; - this.sceneOptions = options?.scene ?? { breakpoints: [], inpoints: [] }; + + this.sceneOptions = { breakpoints: [], inpoints: [] }; + if (options?.scene) { + Object.assign(this.sceneOptions, options.scene); + } + if (options?.layers) { + Object.assign(this.sceneOptions, options.layers); + } } /** * Initialize the object to start everything up. */ start(): void { + this.scrollY = this.getScrollY(); + if (this.debug) { this.showDebugger(); } if (this.container) { - this.scene = new PushInScene( - this.container, - this.sceneOptions, - this.layerOptions - ); - - this.scrollY = this.getScrollY(); - - if (this.debug) { - this.showDebugger(); - } + this.scene = new PushInScene(this); this.setScrollLength(); @@ -101,6 +91,17 @@ export class PushIn { const onScroll = () => { this.scrollY = this.getScrollY(); this.dolly(); + + if (this.pushinDebug) { + const content = this.pushinDebug?.querySelector( + '.pushin-debug__content' + ); + if (content) { + content!.textContent = `Scroll position: ${Math.round( + this.scrollY + )}px`; + } + } }; window.addEventListener('scroll', onScroll); this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); @@ -110,25 +111,13 @@ export class PushIn { clearTimeout(resizeTimeout); resizeTimeout = window.setTimeout(() => { - this.resetLayerParams(); + this.layers.forEach(layer => layer.resetLayerParams()); this.setScrollLength(); this.toggleLayers(); }, 300); }; window.addEventListener('resize', onResize); this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); - - if (this.pushinDebug) { - window.addEventListener('scroll', () => { - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; - const content = this.pushinDebug?.querySelector( - '.pushin-debug__content' - ); - if (content) { - content!.textContent = `Scroll position: ${Math.round(scrollY)}px`; - } - }); - } } /** @@ -187,11 +176,9 @@ export class PushIn { scrollTitle.innerText = 'Pushin.js Debugger'; scrollTitle.classList.add('pushin-debug__title'); - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; - const debuggerContent = document.createElement('div'); debuggerContent.classList.add('pushin-debug__content'); - debuggerContent.innerText = `Scroll position: ${scrollY}px`; + debuggerContent.innerText = `Scroll position: ${this.scrollY}px`; this.pushinDebug.appendChild(scrollTitle); this.pushinDebug.appendChild(debuggerContent); diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts index a9baeb1..8cc0020 100644 --- a/src/pushinLayer.ts +++ b/src/pushinLayer.ts @@ -21,7 +21,7 @@ export class PushInLayer { ) { const inpoints = this.getInpoints(this.element, this.index); const outpoints = this.getOutpoints(this.element, inpoints[0]); - const speed = this.getSpeed(this.element, this.index); + const speed = this.getSpeed(this.element); this.originalScale = this.getElementScaleX(element); this.ref = { inpoints, outpoints, speed }; @@ -49,7 +49,7 @@ export class PushInLayer { } else if (index > 0) { // Set default for middle layers if none provided const { outpoint } = this.scene.layers[index - 1].params; - inpoints = [outpoint - this.speedDelta]; + inpoints = [outpoint - this.scene.speedDelta]; } return inpoints; @@ -59,7 +59,7 @@ export class PushInLayer { * Get all outpoints for the layer. */ private getOutpoints(element: HTMLElement, inpoint: number): number[] { - let outpoints = [inpoint + this.layerDepth]; + let outpoints = [inpoint + this.scene.layerDepth]; if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(','); @@ -74,7 +74,7 @@ export class PushInLayer { /** * Get the push-in speed for the layer. */ - private getSpeed(element: HTMLElement, index: number): number { + private getSpeed(element: HTMLElement): number { let speed: number | null = null; if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { @@ -89,19 +89,6 @@ export class PushInLayer { return speed || DEFAULT_SPEED; } - /** - * Get the array index of the current window breakpoint. - */ - private getBreakpointIndex(): number { - const windowWidth = typeof window !== 'undefined' ? window.innerWidth : 0; - const searchIndex = this.sceneOptions.breakpoints - .reverse() - .findIndex(bp => bp <= windowWidth); - return searchIndex === -1 - ? 0 - : this.sceneOptions.breakpoints.length - 1 - searchIndex; - } - /** * Set the z-index of each layer so they overlap correctly. */ @@ -115,7 +102,7 @@ export class PushInLayer { * This is used if the window is resized * and things need to be recalculated. */ - private resetLayerParams(): void { + resetLayerParams(): void { this.params = { inpoint: this.getInpoint(this.ref.inpoints), outpoint: this.getOutpoint(this.ref.outpoints), @@ -143,31 +130,16 @@ export class PushInLayer { return scaleX; } - /** - * Animation effect, mimicking a camera dolly on the webpage. - */ - private dolly(): void { - cancelAnimationFrame(this.lastAnimationFrameId); - - this.lastAnimationFrameId = requestAnimationFrame(() => { - this.toggleLayers(); - }); - } - - /** - * Show or hide layers and set their scale, depending on if active. - */ - private toggleLayers(): void { - this.layers.forEach(layer => this.setLayerStyle(layer)); - } - /** * Whether or not a layer should currently be zooming. */ private isActive(layer: PushInLayer): boolean { const { inpoint } = layer.params; const { outpoint } = layer.params; - return this.scrollY >= inpoint && this.scrollY <= outpoint; + return ( + this.scene.pushin.scrollY >= inpoint && + this.scene.pushin.scrollY <= outpoint + ); } /** @@ -175,7 +147,7 @@ export class PushInLayer { * depending on window breakpoint. */ private getInpoint(inpoints: number[]): number { - return inpoints[this.getBreakpointIndex()] || inpoints[0]; + return inpoints[this.scene.getBreakpointIndex()] || inpoints[0]; } /** @@ -183,14 +155,14 @@ export class PushInLayer { * depending on window breakpoint. */ private getOutpoint(outpoints: number[]): number { - return outpoints[this.getBreakpointIndex()] || outpoints[0]; + return outpoints[this.scene.getBreakpointIndex()] || outpoints[0]; } /** * Get the scaleX value for the layer. */ private getScaleValue(layer: PushInLayer): number { - const distance = this.scrollY - layer.params.inpoint; + const distance = this.scene.pushin.scrollY - layer.params.inpoint; const speed = Math.min(layer.params.speed, 100) / 100; const delta = (distance * speed) / 100; @@ -222,16 +194,19 @@ export class PushInLayer { const { inpoint } = this.params; const { outpoint } = this.params; - if (isFirst && this.scrollY < inpoint) { + if (isFirst && this.scene.pushin.scrollY < inpoint) { opacity = 1; - } else if (isLast && this.scrollY > outpoint) { + } else if (isLast && this.scene.pushin.scrollY > outpoint) { opacity = 1; } else if (this.isActive(this)) { this.setScale(this.element, this.getScaleValue(this)); let inpointDistance = Math.max( - Math.min(this.scrollY - inpoint, this.scene.transitionLength), + Math.min( + this.scene.pushin.scrollY - inpoint, + this.scene.transitionLength + ), 0 ) / this.scene.transitionLength; @@ -241,8 +216,13 @@ export class PushInLayer { } let outpointDistance = - Math.max(Math.min(outpoint - this.scrollY, this.transitionLength), 0) / - this.transitionLength; + Math.max( + Math.min( + outpoint - this.scene.pushin.scrollY, + this.scene.transitionLength + ), + 0 + ) / this.scene.transitionLength; // Set opacity to 1 if its the last layer and it is active (no fading out) if (isLast) { diff --git a/src/pushinScene.ts b/src/pushinScene.ts index 952a82b..93b6bbe 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -1,13 +1,11 @@ import { - DEFAULT_SPEED, - PUSH_IN_TO_DATA_ATTRIBUTE, PUSH_IN_FROM_DATA_ATTRIBUTE, - PUSH_IN_SPEED_DATA_ATTRIBUTE, PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE, } from './constants'; import { PushInLayer } from './pushinLayer'; +import { PushIn } from './pushin'; -import { SceneOptions, LayerOptions } from './types'; +import { LayerOptions } from './types'; export class PushInScene { private container: HTMLElement; @@ -17,12 +15,9 @@ export class PushInScene { public transitionLength: number; public layerDepth: number; - constructor( - private parent: HTMLElement, - private options?: SceneOptions, - private layerOptions?: LayerOptions[] - ) { - const container = this.parent.querySelector('.pushin-scene'); + constructor(public pushin: PushIn) { + const container = + this.pushin.container.querySelector('.pushin-scene'); if (container) { this.container = container; @@ -30,17 +25,17 @@ export class PushInScene { this.container = document.createElement('div'); this.container.classList.add('pushin-scene'); - this.container.innerHTML = this.parent.innerHTML; - this.parent.innerHTML = ''; - this.parent.appendChild(this.container); + this.container.innerHTML = this.pushin.container.innerHTML; + this.pushin.container.innerHTML = ''; + this.pushin.container.appendChild(this.container); this.cleanupFns.push(() => { - this.parent.innerHTML = this.container.innerHTML; + this.pushin.container.innerHTML = this.container.innerHTML; }); } - this.speedDelta = options?.speedDelta || 100; - this.layerDepth = options?.layerDepth || 1000; - this.transitionLength = options?.transitionLength || 200; + this.speedDelta = pushin.sceneOptions?.speedDelta || 100; + this.layerDepth = pushin.sceneOptions?.layerDepth || 1000; + this.transitionLength = pushin.sceneOptions?.transitionLength || 200; this.layers = []; @@ -52,18 +47,18 @@ export class PushInScene { * Set breakpoints for responsive design settings. */ private setBreakpoints(): void { - if (this.options?.breakpoints.length === 0) { - this.options.breakpoints = [768, 1440, 1920]; + if (this.pushin.sceneOptions?.breakpoints.length === 0) { + this.pushin.sceneOptions.breakpoints = [768, 1440, 1920]; } if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { - this.options!.breakpoints = this.container.dataset[ + this.pushin.sceneOptions!.breakpoints = this.container.dataset[ PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); } // Always include break point 0 for anything under first breakpoint - this.options!.breakpoints.unshift(0); + this.pushin.sceneOptions!.breakpoints.unshift(0); } /** @@ -77,8 +72,11 @@ export class PushInScene { for (let index = 0; index < layers.length; index++) { const element = layers[index]; let options = {}; - if (this.layerOptions && this.layerOptions.length > index) { - options = this!.layerOptions[index]; + if ( + this.pushin.sceneOptions?.layers && + this.pushin.sceneOptions.layers.length > index + ) { + options = this!.pushin.sceneOptions.layers[index]; } const layer = new PushInLayer(element, index, this, options); @@ -91,13 +89,13 @@ export class PushInScene { /** * Get the array index of the current window breakpoint. */ - private getBreakpointIndex(): number { - const searchIndex = this.options!.breakpoints.reverse().findIndex( - bp => bp <= window.innerWidth - ); + getBreakpointIndex(): number { + const searchIndex = this.pushin + .sceneOptions!.breakpoints.reverse() + .findIndex(bp => bp <= window.innerWidth); return searchIndex === -1 ? 0 - : this.options!.breakpoints.length - 1 - searchIndex; + : this.pushin.sceneOptions!.breakpoints.length - 1 - searchIndex; } getTop() { @@ -112,8 +110,8 @@ export class PushInScene { this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE] ); inpoints.push(parseInt(pushInFrom, 10)); - } else if (this.options && this.options?.inpoints?.length > 0) { - inpoints = this.options.inpoints; + } else if (this.pushin.sceneOptions?.inpoints?.length > 0) { + inpoints = this.pushin.sceneOptions.inpoints; } return inpoints; diff --git a/src/types.ts b/src/types.ts index acb8e6f..6377c4d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,6 +10,7 @@ export interface SceneOptions { transitionLength?: number; breakpoints: number[]; inpoints: number[]; + layers?: LayerOptions[]; } export interface PushInOptions { From 62cde45295de9cf3f8a7b61406a18243cde6dc97 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Wed, 27 Apr 2022 21:38:37 -0500 Subject: [PATCH 09/32] #69: WIP - first pass at refactoring unit tests --- test/__mocks__/layerOptions.ts | 5 ++++ test/addScene.spec.ts | 46 --------------------------------- test/getBreakpointIndex.spec.ts | 15 ++++------- 3 files changed, 10 insertions(+), 56 deletions(-) create mode 100644 test/__mocks__/layerOptions.ts delete mode 100644 test/addScene.spec.ts diff --git a/test/__mocks__/layerOptions.ts b/test/__mocks__/layerOptions.ts new file mode 100644 index 0000000..ea26647 --- /dev/null +++ b/test/__mocks__/layerOptions.ts @@ -0,0 +1,5 @@ +export default { + inpoints: [100, 200], + outpoints: [150, 250], + speed: 50, +} diff --git a/test/addScene.spec.ts b/test/addScene.spec.ts deleted file mode 100644 index 9874334..0000000 --- a/test/addScene.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; - -describe('addScene', () => { - let textContent: string; - let pushIn: PushIn; - - beforeEach(() => { - textContent = 'FooBar'; - setupJSDOM(` - - -
-
${textContent}
-
- - `); - - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); - }); - - afterEach(() => pushIn.destroy()); - - it('Should assign existing .pushin-scene element to the scene property', () => { - pushIn['addScene'](); - const result = pushIn['scene'].textContent; - expect(result).toEqual(textContent); - }); - - it("Should create new .pushin-scene element if it doesn't yet exist", () => { - document.querySelector('.pushin-scene').remove(); - pushIn['addScene'](); - const result = pushIn['scene'].classList.contains('pushin-scene'); - expect(result).toEqual(true); - }); - - it('Should move any inner HTML into the new scene element as children', () => { - const innerHTML = 'FooBar'; - document.querySelector('.pushin-scene').remove(); - document.querySelector('.pushin').innerHTML = innerHTML; - pushIn['addScene'](); - const result = pushIn['scene'].innerHTML; - expect(result).toEqual(innerHTML); - }); -}); diff --git a/test/getBreakpointIndex.spec.ts b/test/getBreakpointIndex.spec.ts index b61da68..9e4aee7 100644 --- a/test/getBreakpointIndex.spec.ts +++ b/test/getBreakpointIndex.spec.ts @@ -1,9 +1,7 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInScene } from '../src/pushinScene'; describe('getBreakpointIndex', () => { - let pushIn: PushIn; - beforeEach(() => { setupJSDOM(` @@ -15,21 +13,18 @@ describe('getBreakpointIndex', () => { `); const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); - pushIn['sceneOptions'].breakpoints = [0, 768, 1440, 1920]; + PushInScene.options.breakpoints = [0, 768, 1440, 1920]; }); - afterEach(() => pushIn.destroy()); - it('Should return 0 by default', () => { - pushIn['sceneOptions'].breakpoints = []; - const result = pushIn['getBreakpointIndex'](); + PushInScene.options.breakpoints = []; + const result = PushInScene.prototype.getBreakpointIndex(); expect(result).toEqual(0); }); it('Should return the index of the nearest breakpoint that is less than current window width', () => { window.innerWidth = 800; - const result = pushIn['getBreakpointIndex'](); + const result = PushInScene.prototype.getBreakpointIndex(); expect(result).toEqual(1); }); }); From 99b230b759cec182756ab5beb9704a991e3c3449 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Fri, 29 Apr 2022 18:25:06 -0500 Subject: [PATCH 10/32] #69: WIP - refactoring code and unit tests --- src/pushinLayer.ts | 8 +++++-- src/pushinScene.ts | 40 ++++++++++++++++----------------- test/getBreakpointIndex.spec.ts | 7 ++---- test/getElementScaleX.spec.ts | 16 ++++++------- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts index 8cc0020..852986e 100644 --- a/src/pushinLayer.ts +++ b/src/pushinLayer.ts @@ -147,7 +147,8 @@ export class PushInLayer { * depending on window breakpoint. */ private getInpoint(inpoints: number[]): number { - return inpoints[this.scene.getBreakpointIndex()] || inpoints[0]; + const { breakpoints } = this.scene.options; + return inpoints[this.scene.getBreakpointIndex(breakpoints)] || inpoints[0]; } /** @@ -155,7 +156,10 @@ export class PushInLayer { * depending on window breakpoint. */ private getOutpoint(outpoints: number[]): number { - return outpoints[this.scene.getBreakpointIndex()] || outpoints[0]; + const { breakpoints } = this.scene.options; + return ( + outpoints[this.scene.getBreakpointIndex(breakpoints)] || outpoints[0] + ); } /** diff --git a/src/pushinScene.ts b/src/pushinScene.ts index 93b6bbe..e22ae6a 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -5,7 +5,7 @@ import { import { PushInLayer } from './pushinLayer'; import { PushIn } from './pushin'; -import { LayerOptions } from './types'; +import { LayerOptions, SceneOptions } from './types'; export class PushInScene { private container: HTMLElement; @@ -14,6 +14,7 @@ export class PushInScene { public speedDelta: number; public transitionLength: number; public layerDepth: number; + public options: SceneOptions; constructor(public pushin: PushIn) { const container = @@ -33,9 +34,11 @@ export class PushInScene { }); } - this.speedDelta = pushin.sceneOptions?.speedDelta || 100; - this.layerDepth = pushin.sceneOptions?.layerDepth || 1000; - this.transitionLength = pushin.sceneOptions?.transitionLength || 200; + this.options = pushin.sceneOptions; + + this.speedDelta = this.options?.speedDelta || 100; + this.layerDepth = this.options?.layerDepth || 1000; + this.transitionLength = this.options?.transitionLength || 200; this.layers = []; @@ -47,18 +50,18 @@ export class PushInScene { * Set breakpoints for responsive design settings. */ private setBreakpoints(): void { - if (this.pushin.sceneOptions?.breakpoints.length === 0) { - this.pushin.sceneOptions.breakpoints = [768, 1440, 1920]; + if (this.options?.breakpoints.length === 0) { + this.options.breakpoints = [768, 1440, 1920]; } if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { - this.pushin.sceneOptions!.breakpoints = this.container.dataset[ + this.options!.breakpoints = this.container.dataset[ PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); } // Always include break point 0 for anything under first breakpoint - this.pushin.sceneOptions!.breakpoints.unshift(0); + this.options!.breakpoints.unshift(0); } /** @@ -72,11 +75,8 @@ export class PushInScene { for (let index = 0; index < layers.length; index++) { const element = layers[index]; let options = {}; - if ( - this.pushin.sceneOptions?.layers && - this.pushin.sceneOptions.layers.length > index - ) { - options = this!.pushin.sceneOptions.layers[index]; + if (this.options?.layers && this.options.layers.length > index) { + options = this!.options.layers[index]; } const layer = new PushInLayer(element, index, this, options); @@ -89,13 +89,11 @@ export class PushInScene { /** * Get the array index of the current window breakpoint. */ - getBreakpointIndex(): number { - const searchIndex = this.pushin - .sceneOptions!.breakpoints.reverse() + getBreakpointIndex(breakpoints: number[]): number { + const searchIndex = breakpoints + .reverse() .findIndex(bp => bp <= window.innerWidth); - return searchIndex === -1 - ? 0 - : this.pushin.sceneOptions!.breakpoints.length - 1 - searchIndex; + return searchIndex === -1 ? 0 : breakpoints.length - 1 - searchIndex; } getTop() { @@ -110,8 +108,8 @@ export class PushInScene { this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE] ); inpoints.push(parseInt(pushInFrom, 10)); - } else if (this.pushin.sceneOptions?.inpoints?.length > 0) { - inpoints = this.pushin.sceneOptions.inpoints; + } else if (this.options?.inpoints?.length > 0) { + inpoints = this.options.inpoints; } return inpoints; diff --git a/test/getBreakpointIndex.spec.ts b/test/getBreakpointIndex.spec.ts index 9e4aee7..1d7184f 100644 --- a/test/getBreakpointIndex.spec.ts +++ b/test/getBreakpointIndex.spec.ts @@ -11,20 +11,17 @@ describe('getBreakpointIndex', () => { `); - const container = document.querySelector('.pushin'); - PushInScene.options.breakpoints = [0, 768, 1440, 1920]; }); it('Should return 0 by default', () => { - PushInScene.options.breakpoints = []; - const result = PushInScene.prototype.getBreakpointIndex(); + const result = PushInScene.prototype.getBreakpointIndex([]); expect(result).toEqual(0); }); it('Should return the index of the nearest breakpoint that is less than current window width', () => { window.innerWidth = 800; - const result = PushInScene.prototype.getBreakpointIndex(); + const result = PushInScene.prototype.getBreakpointIndex([0, 768, 1440, 1920]); expect(result).toEqual(1); }); }); diff --git a/test/getElementScaleX.spec.ts b/test/getElementScaleX.spec.ts index 988fa13..b21f15c 100644 --- a/test/getElementScaleX.spec.ts +++ b/test/getElementScaleX.spec.ts @@ -1,18 +1,18 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushinLayer'; describe('getElementScaleX', () => { - let pushIn: PushIn; + let pushInLayer: PushInLayer; beforeEach(() => { setupJSDOM(` - - -
Hello World!
- - `); + + +
Hello World!
+ + `); - pushIn = new PushIn(null); + pushInLayer = new PushInLayer(null); }); afterEach(() => pushIn.destroy()); From 8761a9f1d39367c7d9b646fc7ad65037cdb8f378 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 1 May 2022 06:19:14 -0500 Subject: [PATCH 11/32] unit tests for getElementScaleX + rename files to match class names --- src/pushin.ts | 4 ++-- src/pushinLayer.ts | 2 +- src/pushinScene.ts | 2 +- test/getElementScaleX.spec.ts | 22 ++++++++++------------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pushin.ts b/src/pushin.ts index c2ff3af..ad4a3ea 100644 --- a/src/pushin.ts +++ b/src/pushin.ts @@ -1,5 +1,5 @@ -import { PushInScene } from './pushinScene'; -import { PushInLayer } from './pushinLayer'; +import { PushInScene } from './pushInScene'; +import { PushInLayer } from './pushInLayer'; import { PushInOptions, SceneOptions } from './types'; diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts index 852986e..6c2eeb8 100644 --- a/src/pushinLayer.ts +++ b/src/pushinLayer.ts @@ -4,7 +4,7 @@ import { PUSH_IN_FROM_DATA_ATTRIBUTE, PUSH_IN_SPEED_DATA_ATTRIBUTE, } from './constants'; -import { PushInScene } from './pushinScene'; +import { PushInScene } from './pushInScene'; import { LayerOptions, LayerRef, LayerParams } from './types'; diff --git a/src/pushinScene.ts b/src/pushinScene.ts index e22ae6a..f82157d 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -2,7 +2,7 @@ import { PUSH_IN_FROM_DATA_ATTRIBUTE, PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE, } from './constants'; -import { PushInLayer } from './pushinLayer'; +import { PushInLayer } from './pushInLayer'; import { PushIn } from './pushin'; import { LayerOptions, SceneOptions } from './types'; diff --git a/test/getElementScaleX.spec.ts b/test/getElementScaleX.spec.ts index b21f15c..7da41c5 100644 --- a/test/getElementScaleX.spec.ts +++ b/test/getElementScaleX.spec.ts @@ -1,8 +1,10 @@ import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushinLayer'; +import { PushInLayer } from '../src/pushInLayer'; describe('getElementScaleX', () => { - let pushInLayer: PushInLayer; + let element: HTMLElement; + let mockPushInLayer: PushInLayer; + jest.mock('../src/pushInLayer', () => jest.fn()); beforeEach(() => { setupJSDOM(` @@ -12,25 +14,21 @@ describe('getElementScaleX', () => { `); - pushInLayer = new PushInLayer(null); + element = document.querySelector('.foo'); + mockPushInLayer = Object.create(PushInLayer.prototype); + mockPushInLayer['element'] = element; }); - afterEach(() => pushIn.destroy()); + // afterEach(() => pushInLayer.destroy()); it('Should return default element scale if never altered', () => { - const element = document.querySelector('.foo'); - const result = pushIn['getElementScaleX'](element); - + const result = mockPushInLayer['getElementScaleX'](element); expect(result).toEqual(1); }); it('Should return element scale if it was previously set', () => { - const element = document.querySelector('.foo'); - element.style.transform = 'scale(5)'; - - const result = pushIn['getElementScaleX'](element); - + const result = mockPushInLayer['getElementScaleX'](element); expect(result).toEqual(5); }); }); From bd64d57b86abb33d9a684ec3a689e0539068117f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 04:18:35 +0000 Subject: [PATCH 12/32] Bump @typescript-eslint/parser from 5.19.0 to 5.21.0 Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.19.0 to 5.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.21.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 250 +++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..b4eece7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2949,14 +2949,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", + "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", "debug": "^4.3.2" }, "engines": { @@ -2975,14 +2975,14 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2992,10 +2992,36 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "node_modules/@typescript-eslint/type-utils": { "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", + "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "5.19.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3005,14 +3031,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -3032,24 +3058,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/globby": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", @@ -3069,7 +3078,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@typescript-eslint/parser/node_modules/lru-cache": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", @@ -3081,7 +3090,7 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/parser/node_modules/semver": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", @@ -3096,32 +3105,6 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "dependencies": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, "node_modules/@typescript-eslint/utils": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", @@ -3289,6 +3272,23 @@ "node": ">=10" } }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -14978,58 +14978,59 @@ } }, "@typescript-eslint/parser": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz", - "integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", + "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", "debug": "^4.3.2" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", + "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "5.19.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -15064,17 +15065,6 @@ } } }, - "@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", - "dev": true, - "requires": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - } - }, "@typescript-eslint/utils": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", @@ -15180,6 +15170,16 @@ } } }, + "@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "dev": true, From c61cd86f1a8adcc9d8cbbd2b568845b00cd049bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 04:18:48 +0000 Subject: [PATCH 13/32] Bump @babel/core from 7.17.9 to 7.17.10 Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.17.9 to 7.17.10. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.17.10/packages/babel-core) --- updated-dependencies: - dependency-name: "@babel/core" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 165 +++++++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 59 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..27ffac7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,28 +76,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.10.tgz", + "integrity": "sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz", + "integrity": "sha512-liKoppandF3ZcBnIYFjfSDHZLKdLHGJRkoWtG8zQyGJBQfIYobpnVGI5+pLBNtS6psFLDzyq8+h5HiVljW9PNA==", "dev": true, - "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-compilation-targets": "^7.17.7", + "@babel/generator": "^7.17.10", + "@babel/helper-compilation-targets": "^7.17.10", "@babel/helper-module-transforms": "^7.17.7", "@babel/helpers": "^7.17.9", - "@babel/parser": "^7.17.9", + "@babel/parser": "^7.17.10", "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0", + "@babel/traverse": "^7.17.10", + "@babel/types": "^7.17.10", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -113,13 +115,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.10.tgz", + "integrity": "sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "@babel/types": "^7.17.10", + "@jridgewell/gen-mapping": "^0.1.0", + "jsesc": "^2.5.1" }, "engines": { "node": ">=6.9.0" @@ -149,13 +152,14 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.10.tgz", + "integrity": "sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.17.7", + "@babel/compat-data": "^7.17.10", "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "browserslist": "^4.20.2", "semver": "^6.3.0" }, "engines": { @@ -440,9 +444,10 @@ } }, "node_modules/@babel/parser": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.10.tgz", + "integrity": "sha512-n2Q6i+fnJqzOaq2VkdXxy2TCPCWQZHiCo0XqmrCvDWcZQKRyZzYi4Z0yxlBuN0w+r2ZHmre+Q087DSrw3pbJDQ==", "dev": true, - "license": "MIT", "bin": { "parser": "bin/babel-parser.js" }, @@ -1516,18 +1521,19 @@ } }, "node_modules/@babel/traverse": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.10.tgz", + "integrity": "sha512-VmbrTHQteIdUUQNTb+zE12SHS/xQVIShmBPhlNP12hD5poF2pbITW1Z4172d03HegaQWhLffdkRJYtAzp0AGcw==", "dev": true, - "license": "MIT", "dependencies": { "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", + "@babel/generator": "^7.17.10", "@babel/helper-environment-visitor": "^7.16.7", "@babel/helper-function-name": "^7.17.9", "@babel/helper-hoist-variables": "^7.16.7", "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.9", - "@babel/types": "^7.17.0", + "@babel/parser": "^7.17.10", + "@babel/types": "^7.17.10", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1536,9 +1542,10 @@ } }, "node_modules/@babel/types": { - "version": "7.17.0", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.10.tgz", + "integrity": "sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==", "dev": true, - "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.16.7", "to-fast-properties": "^2.0.0" @@ -2392,6 +2399,19 @@ "node": ">=8" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.0.5", "dev": true, @@ -2400,6 +2420,15 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.0.tgz", + "integrity": "sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.11", "dev": true, @@ -11296,14 +11325,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/source-map": { - "version": "0.5.7", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-js": { "version": "1.0.2", "dev": true, @@ -13029,23 +13050,27 @@ } }, "@babel/compat-data": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.10.tgz", + "integrity": "sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==", "dev": true }, "@babel/core": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.10.tgz", + "integrity": "sha512-liKoppandF3ZcBnIYFjfSDHZLKdLHGJRkoWtG8zQyGJBQfIYobpnVGI5+pLBNtS6psFLDzyq8+h5HiVljW9PNA==", "dev": true, "requires": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", - "@babel/helper-compilation-targets": "^7.17.7", + "@babel/generator": "^7.17.10", + "@babel/helper-compilation-targets": "^7.17.10", "@babel/helper-module-transforms": "^7.17.7", "@babel/helpers": "^7.17.9", - "@babel/parser": "^7.17.9", + "@babel/parser": "^7.17.10", "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.9", - "@babel/types": "^7.17.0", + "@babel/traverse": "^7.17.10", + "@babel/types": "^7.17.10", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -13054,12 +13079,14 @@ } }, "@babel/generator": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.10.tgz", + "integrity": "sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg==", "dev": true, "requires": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "@babel/types": "^7.17.10", + "@jridgewell/gen-mapping": "^0.1.0", + "jsesc": "^2.5.1" } }, "@babel/helper-annotate-as-pure": { @@ -13078,12 +13105,14 @@ } }, "@babel/helper-compilation-targets": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.10.tgz", + "integrity": "sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ==", "dev": true, "requires": { - "@babel/compat-data": "^7.17.7", + "@babel/compat-data": "^7.17.10", "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "browserslist": "^4.20.2", "semver": "^6.3.0" } }, @@ -13268,7 +13297,9 @@ } }, "@babel/parser": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.10.tgz", + "integrity": "sha512-n2Q6i+fnJqzOaq2VkdXxy2TCPCWQZHiCo0XqmrCvDWcZQKRyZzYi4Z0yxlBuN0w+r2ZHmre+Q087DSrw3pbJDQ==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -13898,23 +13929,27 @@ } }, "@babel/traverse": { - "version": "7.17.9", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.10.tgz", + "integrity": "sha512-VmbrTHQteIdUUQNTb+zE12SHS/xQVIShmBPhlNP12hD5poF2pbITW1Z4172d03HegaQWhLffdkRJYtAzp0AGcw==", "dev": true, "requires": { "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.9", + "@babel/generator": "^7.17.10", "@babel/helper-environment-visitor": "^7.16.7", "@babel/helper-function-name": "^7.17.9", "@babel/helper-hoist-variables": "^7.16.7", "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.9", - "@babel/types": "^7.17.0", + "@babel/parser": "^7.17.10", + "@babel/types": "^7.17.10", "debug": "^4.1.0", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.17.0", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.10.tgz", + "integrity": "sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.16.7", @@ -14539,10 +14574,26 @@ } } }, + "@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@jridgewell/resolve-uri": { "version": "3.0.5", "dev": true }, + "@jridgewell/set-array": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.0.tgz", + "integrity": "sha512-SfJxIxNVYLTsKwzB3MoOQ1yxf4w/E6MdkvTgrgAt1bfxjSrLUoHMKrDOykwN14q65waezZIdqDneUIPh4/sKxg==", + "dev": true + }, "@jridgewell/sourcemap-codec": { "version": "1.4.11", "dev": true @@ -20607,10 +20658,6 @@ } } }, - "source-map": { - "version": "0.5.7", - "dev": true - }, "source-map-js": { "version": "1.0.2", "dev": true From 91a244bb51dfa682a24bfa0cf39638803d5e9c7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 04:19:12 +0000 Subject: [PATCH 14/32] Bump @babel/preset-env from 7.16.11 to 7.17.10 Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.16.11 to 7.17.10. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.17.10/packages/babel-preset-env) --- updated-dependencies: - dependency-name: "@babel/preset-env" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 168 +++++++++++++++++++++++++++------------------- 1 file changed, 99 insertions(+), 69 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..de9a4bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,9 +76,10 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.10.tgz", + "integrity": "sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -149,13 +150,14 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.10.tgz", + "integrity": "sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.17.7", + "@babel/compat-data": "^7.17.10", "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "browserslist": "^4.20.2", "semver": "^6.3.0" }, "engines": { @@ -1191,11 +1193,12 @@ } }, "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.17.10.tgz", + "integrity": "sha512-v54O6yLaJySCs6mGzaVOUw9T967GnH38T6CQSAtnzdNPwu84l2qAjssKzo/WSO8Yi7NF+7ekm5cVbF/5qiIgNA==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.17.0" }, "engines": { "node": ">=6.9.0" @@ -1390,26 +1393,27 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.16.11", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz", + "integrity": "sha512-YNgyBHZQpeoBSRBg0xixsZzfT58Ze1iZrajvv0lJc70qDDGuGfonEnMGfWeSY0mQ3JTuCWFbMkzFRVafOyJx4g==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", + "@babel/compat-data": "^7.17.10", + "@babel/helper-compilation-targets": "^7.17.10", "@babel/helper-plugin-utils": "^7.16.7", "@babel/helper-validator-option": "^7.16.7", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", "@babel/plugin-proposal-async-generator-functions": "^7.16.8", "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", + "@babel/plugin-proposal-class-static-block": "^7.17.6", "@babel/plugin-proposal-dynamic-import": "^7.16.7", "@babel/plugin-proposal-export-namespace-from": "^7.16.7", "@babel/plugin-proposal-json-strings": "^7.16.7", "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", + "@babel/plugin-proposal-object-rest-spread": "^7.17.3", "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-proposal-private-methods": "^7.16.11", @@ -1435,7 +1439,7 @@ "@babel/plugin-transform-block-scoping": "^7.16.7", "@babel/plugin-transform-classes": "^7.16.7", "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", + "@babel/plugin-transform-destructuring": "^7.17.7", "@babel/plugin-transform-dotall-regex": "^7.16.7", "@babel/plugin-transform-duplicate-keys": "^7.16.7", "@babel/plugin-transform-exponentiation-operator": "^7.16.7", @@ -1444,15 +1448,15 @@ "@babel/plugin-transform-literals": "^7.16.7", "@babel/plugin-transform-member-expression-literals": "^7.16.7", "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", + "@babel/plugin-transform-modules-commonjs": "^7.17.9", + "@babel/plugin-transform-modules-systemjs": "^7.17.8", "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.17.10", "@babel/plugin-transform-new-target": "^7.16.7", "@babel/plugin-transform-object-super": "^7.16.7", "@babel/plugin-transform-parameters": "^7.16.7", "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", + "@babel/plugin-transform-regenerator": "^7.17.9", "@babel/plugin-transform-reserved-words": "^7.16.7", "@babel/plugin-transform-shorthand-properties": "^7.16.7", "@babel/plugin-transform-spread": "^7.16.7", @@ -1462,11 +1466,11 @@ "@babel/plugin-transform-unicode-escapes": "^7.16.7", "@babel/plugin-transform-unicode-regex": "^7.16.7", "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", + "@babel/types": "^7.17.10", "babel-plugin-polyfill-corejs2": "^0.3.0", "babel-plugin-polyfill-corejs3": "^0.5.0", "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", + "core-js-compat": "^3.22.1", "semver": "^6.3.0" }, "engines": { @@ -1536,9 +1540,10 @@ } }, "node_modules/@babel/types": { - "version": "7.17.0", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.10.tgz", + "integrity": "sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==", "dev": true, - "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.16.7", "to-fast-properties": "^2.0.0" @@ -4104,7 +4109,9 @@ "license": "BSD-2-Clause" }, "node_modules/browserslist": { - "version": "4.20.2", + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", + "integrity": "sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg==", "dev": true, "funding": [ { @@ -4116,12 +4123,11 @@ "url": "https://tidelift.com/funding/github/npm/browserslist" } ], - "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", + "caniuse-lite": "^1.0.30001332", + "electron-to-chromium": "^1.4.118", "escalade": "^3.1.1", - "node-releases": "^2.0.2", + "node-releases": "^2.0.3", "picocolors": "^1.0.0" }, "bin": { @@ -4203,7 +4209,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001327", + "version": "1.0.30001334", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001334.tgz", + "integrity": "sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==", "dev": true, "funding": [ { @@ -4214,8 +4222,7 @@ "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" } - ], - "license": "CC-BY-4.0" + ] }, "node_modules/chalk": { "version": "2.4.2", @@ -4613,11 +4620,12 @@ "license": "MIT" }, "node_modules/core-js-compat": { - "version": "3.21.1", + "version": "3.22.3", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.3.tgz", + "integrity": "sha512-wliMbvPI2idgFWpFe7UEyHMvu6HWgW8WA+HnDRtgzoSDYvXFMpoGX1H3tPDDXrcfUSyXafCLDd7hOeMQHEZxGw==", "dev": true, - "license": "MIT", "dependencies": { - "browserslist": "^4.19.1", + "browserslist": "^4.20.3", "semver": "7.0.0" }, "funding": { @@ -5051,9 +5059,10 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.106", - "dev": true, - "license": "ISC" + "version": "1.4.129", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.129.tgz", + "integrity": "sha512-GgtN6bsDtHdtXJtlMYZWGB/uOyjZWjmRDumXTas7dGBaB9zUyCjzHet1DY2KhyHN8R0GLbzZWqm4efeddqqyRQ==", + "dev": true }, "node_modules/emittery": { "version": "0.8.1", @@ -9790,9 +9799,10 @@ "dev": true }, "node_modules/node-releases": { - "version": "2.0.2", - "dev": true, - "license": "MIT" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz", + "integrity": "sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==", + "dev": true }, "node_modules/normalize-path": { "version": "3.0.0", @@ -13029,7 +13039,9 @@ } }, "@babel/compat-data": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.10.tgz", + "integrity": "sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==", "dev": true }, "@babel/core": { @@ -13078,12 +13090,14 @@ } }, "@babel/helper-compilation-targets": { - "version": "7.17.7", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.10.tgz", + "integrity": "sha512-gh3RxjWbauw/dFiU/7whjd0qN9K6nPJMqe6+Er7rOavFh0CQUSwhAE3IcTho2rywPJFxej6TUUHDkWcYI6gGqQ==", "dev": true, "requires": { - "@babel/compat-data": "^7.17.7", + "@babel/compat-data": "^7.17.10", "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "browserslist": "^4.20.2", "semver": "^6.3.0" } }, @@ -13690,10 +13704,12 @@ } }, "@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.17.10.tgz", + "integrity": "sha512-v54O6yLaJySCs6mGzaVOUw9T967GnH38T6CQSAtnzdNPwu84l2qAjssKzo/WSO8Yi7NF+7ekm5cVbF/5qiIgNA==", "dev": true, "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.17.0" } }, "@babel/plugin-transform-new-target": { @@ -13791,25 +13807,27 @@ } }, "@babel/preset-env": { - "version": "7.16.11", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.17.10.tgz", + "integrity": "sha512-YNgyBHZQpeoBSRBg0xixsZzfT58Ze1iZrajvv0lJc70qDDGuGfonEnMGfWeSY0mQ3JTuCWFbMkzFRVafOyJx4g==", "dev": true, "requires": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", + "@babel/compat-data": "^7.17.10", + "@babel/helper-compilation-targets": "^7.17.10", "@babel/helper-plugin-utils": "^7.16.7", "@babel/helper-validator-option": "^7.16.7", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", "@babel/plugin-proposal-async-generator-functions": "^7.16.8", "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", + "@babel/plugin-proposal-class-static-block": "^7.17.6", "@babel/plugin-proposal-dynamic-import": "^7.16.7", "@babel/plugin-proposal-export-namespace-from": "^7.16.7", "@babel/plugin-proposal-json-strings": "^7.16.7", "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", + "@babel/plugin-proposal-object-rest-spread": "^7.17.3", "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-proposal-private-methods": "^7.16.11", @@ -13835,7 +13853,7 @@ "@babel/plugin-transform-block-scoping": "^7.16.7", "@babel/plugin-transform-classes": "^7.16.7", "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", + "@babel/plugin-transform-destructuring": "^7.17.7", "@babel/plugin-transform-dotall-regex": "^7.16.7", "@babel/plugin-transform-duplicate-keys": "^7.16.7", "@babel/plugin-transform-exponentiation-operator": "^7.16.7", @@ -13844,15 +13862,15 @@ "@babel/plugin-transform-literals": "^7.16.7", "@babel/plugin-transform-member-expression-literals": "^7.16.7", "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", + "@babel/plugin-transform-modules-commonjs": "^7.17.9", + "@babel/plugin-transform-modules-systemjs": "^7.17.8", "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.17.10", "@babel/plugin-transform-new-target": "^7.16.7", "@babel/plugin-transform-object-super": "^7.16.7", "@babel/plugin-transform-parameters": "^7.16.7", "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", + "@babel/plugin-transform-regenerator": "^7.17.9", "@babel/plugin-transform-reserved-words": "^7.16.7", "@babel/plugin-transform-shorthand-properties": "^7.16.7", "@babel/plugin-transform-spread": "^7.16.7", @@ -13862,11 +13880,11 @@ "@babel/plugin-transform-unicode-escapes": "^7.16.7", "@babel/plugin-transform-unicode-regex": "^7.16.7", "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", + "@babel/types": "^7.17.10", "babel-plugin-polyfill-corejs2": "^0.3.0", "babel-plugin-polyfill-corejs3": "^0.5.0", "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", + "core-js-compat": "^3.22.1", "semver": "^6.3.0" } }, @@ -13914,7 +13932,9 @@ } }, "@babel/types": { - "version": "7.17.0", + "version": "7.17.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.10.tgz", + "integrity": "sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.16.7", @@ -15767,13 +15787,15 @@ "dev": true }, "browserslist": { - "version": "4.20.2", + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", + "integrity": "sha512-NBhymBQl1zM0Y5dQT/O+xiLP9/rzOIQdKM/eMJBAq7yBgaB6krIYLGejrwVYnSHZdqjscB1SPuAjHwxjvN6Wdg==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001317", - "electron-to-chromium": "^1.4.84", + "caniuse-lite": "^1.0.30001332", + "electron-to-chromium": "^1.4.118", "escalade": "^3.1.1", - "node-releases": "^2.0.2", + "node-releases": "^2.0.3", "picocolors": "^1.0.0" } }, @@ -15828,7 +15850,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001327", + "version": "1.0.30001334", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001334.tgz", + "integrity": "sha512-kbaCEBRRVSoeNs74sCuq92MJyGrMtjWVfhltoHUCW4t4pXFvGjUBrfo47weBRViHkiV3eBYyIsfl956NtHGazw==", "dev": true }, "chalk": { @@ -16102,10 +16126,12 @@ "dev": true }, "core-js-compat": { - "version": "3.21.1", + "version": "3.22.3", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.22.3.tgz", + "integrity": "sha512-wliMbvPI2idgFWpFe7UEyHMvu6HWgW8WA+HnDRtgzoSDYvXFMpoGX1H3tPDDXrcfUSyXafCLDd7hOeMQHEZxGw==", "dev": true, "requires": { - "browserslist": "^4.19.1", + "browserslist": "^4.20.3", "semver": "7.0.0" }, "dependencies": { @@ -16385,7 +16411,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.4.106", + "version": "1.4.129", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.129.tgz", + "integrity": "sha512-GgtN6bsDtHdtXJtlMYZWGB/uOyjZWjmRDumXTas7dGBaB9zUyCjzHet1DY2KhyHN8R0GLbzZWqm4efeddqqyRQ==", "dev": true }, "emittery": { @@ -19602,7 +19630,9 @@ "dev": true }, "node-releases": { - "version": "2.0.2", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz", + "integrity": "sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==", "dev": true }, "normalize-path": { From 840a9b93185911baf627b31fda4941256d725b89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 04:19:31 +0000 Subject: [PATCH 15/32] Bump @typescript-eslint/eslint-plugin from 5.19.0 to 5.21.0 Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.19.0 to 5.21.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.21.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 429 +++++++++++++++++++--------------------------- 1 file changed, 179 insertions(+), 250 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..f823b2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2855,14 +2855,14 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", + "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/type-utils": "5.21.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -2887,53 +2887,6 @@ } } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { "version": "7.3.6", "dev": true, @@ -3096,15 +3049,14 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", "dev": true, "dependencies": { - "@typescript-eslint/utils": "5.19.0", - "debug": "^4.3.2", - "tsutils": "^3.21.0" + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3112,28 +3064,17 @@ "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } } }, - "node_modules/@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", + "node_modules/@typescript-eslint/type-utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", + "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", "dev": true, "dependencies": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "@typescript-eslint/utils": "5.21.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3143,30 +3084,18 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "eslint": "*" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", + "node_modules/@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3176,14 +3105,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -3203,46 +3132,7 @@ } } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/globby": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", @@ -3262,7 +3152,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", @@ -3274,7 +3164,7 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/utils/node_modules/semver": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", @@ -3289,6 +3179,69 @@ "node": ">=10" } }, + "node_modules/@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.1", "dev": true, @@ -14926,14 +14879,14 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz", - "integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", + "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/type-utils": "5.19.0", - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/type-utils": "5.21.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -14942,32 +14895,6 @@ "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, "semver": { "version": "7.3.6", "dev": true, @@ -15064,88 +14991,48 @@ } } }, + "@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + } + }, "@typescript-eslint/type-utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz", - "integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", + "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", "dev": true, "requires": { - "@typescript-eslint/utils": "5.19.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "tsutils": "^3.21.0" } }, - "@typescript-eslint/utils": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz", - "integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==", + "@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", "dev": true, "requires": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.19.0", - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/typescript-estree": "5.19.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { - "@typescript-eslint/scope-manager": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz", - "integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0" - } - }, - "@typescript-eslint/types": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz", - "integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz", - "integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "@typescript-eslint/visitor-keys": "5.19.0", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz", - "integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.19.0", - "eslint-visitor-keys": "^3.0.0" - } - }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -15180,6 +15067,48 @@ } } }, + "@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + } + }, "@webassemblyjs/ast": { "version": "1.11.1", "dev": true, From 5b8e161cc99defb3effbb16d92ced918f210da96 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Mon, 2 May 2022 20:27:43 -0500 Subject: [PATCH 16/32] #69: Unit tests for layer.getInpoints --- test/getInpoints.spec.ts | 46 +++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/test/getInpoints.spec.ts b/test/getInpoints.spec.ts index 88bd332..648b79a 100644 --- a/test/getInpoints.spec.ts +++ b/test/getInpoints.spec.ts @@ -1,8 +1,10 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushInLayer'; +import { PushInScene } from '../src/pushInScene'; describe('getInpoints', () => { - let pushIn: PushIn; + let mockPushInLayer: PushInLayer; + let mockPushInScene: PushInScene; beforeEach(() => { setupJSDOM(` @@ -19,56 +21,46 @@ describe('getInpoints', () => { `); - pushIn = new PushIn(null); - pushIn['scene'] = document.querySelector('.pushin-scene'); - pushIn['scene'].getBoundingClientRect = () => { - return { top: 10 } as unknown as DOMRect; + const mockLayer1 = Object.create(PushInLayer.prototype); + mockLayer1['params'] = { + outpoint: 1000, }; - pushIn['speedDelta'] = 100; - (pushIn as any).layers = [ + mockPushInScene = Object.create(PushInScene.prototype); + mockPushInScene['getTop'] = () => 0; + mockPushInScene['getInpoints'] = () => [10]; + mockPushInScene['layers'] = [ null, null, - { - params: { - outpoint: 1000, - }, - }, + mockLayer1 ]; - }); - - afterEach(() => pushIn.destroy()); + mockPushInScene['speedDelta'] = 100; - it('Should return scene[pushinFrom] value, if available for first layer', () => { - // const scene = document.querySelector( '.pushin-scene' ); - pushIn['scene'].setAttribute('data-pushin-from', '30'); - - const elem = document.querySelector('#layer-0'); - const result = pushIn['getInpoints'](elem, 0); - expect(result).toEqual([30]); + mockPushInLayer = Object.create(PushInLayer.prototype); + mockPushInLayer['scene'] = mockPushInScene; }); it('Should return scene top value as the default for first layer', () => { const elem = document.querySelector('#layer-0'); - const result = pushIn['getInpoints'](elem, 0); + const result = mockPushInLayer['getInpoints'](elem, 0); expect(result).toEqual([10]); }); it('Should return value provided by data attribute', () => { const elem = document.querySelector('#layer-1'); - const result = pushIn['getInpoints'](elem, 1); + const result = mockPushInLayer['getInpoints'](elem, 1); expect(result).toEqual([300]); }); it('Should return array of values provided by data attribute', () => { const elem = document.querySelector('#layer-2'); - const result = pushIn['getInpoints'](elem, 2); + const result = mockPushInLayer['getInpoints'](elem, 2); expect(result).toEqual([300, 500]); }); it('Should return generated value based on previous layer outpoint', () => { const elem = document.querySelector('#layer-3'); - const result = pushIn['getInpoints'](elem, 3); + const result = mockPushInLayer['getInpoints'](elem, 3); expect(result).toEqual([900]); }); }); From cce955cc66b76ecccec69874e0b212667fef755d Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Wed, 4 May 2022 20:54:37 -0500 Subject: [PATCH 17/32] #69: Update getLayers unit test --- test/getLayers.spec.ts | 82 ++++++++---------------------------------- 1 file changed, 14 insertions(+), 68 deletions(-) diff --git a/test/getLayers.spec.ts b/test/getLayers.spec.ts index 344874a..4d9c061 100644 --- a/test/getLayers.spec.ts +++ b/test/getLayers.spec.ts @@ -1,11 +1,14 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInScene } from '../src/pushInScene'; +import { PushInLayer } from '../src/pushInLayer'; +jest.mock('../src/pushInLayer'); describe('getLayers', () => { - let pushIn: PushIn; + let mockPushInScene: PushInScene; let layers: HTMLElement[]; beforeEach(() => { + (PushInLayer as jest.Mock).mockClear(); setupJSDOM(` @@ -20,77 +23,20 @@ describe('getLayers', () => { `); - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); - const scene = document.querySelector('.pushin-scene'); - pushIn['scene'] = scene; + mockPushInScene = Object.create(PushInScene.prototype); + mockPushInScene['container'] = document.querySelector('.pushin-scene'); + mockPushInScene['layers'] = []; - layers = [...document.querySelectorAll('.pushin-layer')]; - - // Mock some methods - Object.assign(pushIn, { - getInpoints: () => [1, 2], - getInpoint: () => 1, - getOutpoints: () => [3, 4], - getOutpoint: () => 3, - getElementScaleX: () => 123, - getSpeed: () => 5, - setZIndex: () => {}, - }); + layers = [ ...document.querySelectorAll('.pushin-layer')]; }); - afterEach(() => pushIn.destroy()); - it('Should set the layers property to contain all .pushin-layer elements', () => { - pushIn['getLayers'](); - expect(pushIn['layers'].length).toEqual(layers.length); - }); - - it('Should include the element for each layer', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].element.id; - expect(result).toEqual('layer-0'); - }); - - it('Should include the index of each layer', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].index; - expect(result).toEqual(0); - }); - - it('Should include the original scale of each layer', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][1].originalScale; - expect(result).toEqual(123); - }); - - it('Should include reference inpoints array', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][2].ref.inpoints; - expect(result).toEqual([1, 2]); - }); - - it('Should include reference outpoints array', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].ref.outpoints; - expect(result).toEqual([3, 4]); - }); - - it('Should include the inpoint param', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].params.inpoint; - expect(result).toEqual(1); - }); - - it('Should include the outpoint param', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].params.outpoint; - expect(result).toEqual(3); + mockPushInScene['getLayers'](); + expect(mockPushInScene['layers'].length).toEqual(layers.length); }); - it('Should include the speed param', () => { - pushIn['getLayers'](); - const result = pushIn['layers'][0].params.speed; - expect(result).toEqual(5); + it('Should create pushInLayer with correct arguments', () => { + mockPushInScene['getLayers'](); + expect(PushInLayer).toHaveBeenCalledWith(layers[1], 1, mockPushInScene, {}); }); }); From 4dffedca934ef6ec06d6b312970c300619e1bdc0 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Wed, 4 May 2022 22:19:06 -0500 Subject: [PATCH 18/32] #69: Update unit tests for getOutpoints and getScaleValue methods --- test/getOutpoints.spec.ts | 52 ++++++++++++++++++------------------- test/getScaleValue.spec.ts | 53 ++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 51 deletions(-) diff --git a/test/getOutpoints.spec.ts b/test/getOutpoints.spec.ts index 4dceb8b..f79cf6b 100644 --- a/test/getOutpoints.spec.ts +++ b/test/getOutpoints.spec.ts @@ -1,69 +1,69 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInScene } from '../src/pushInScene'; +import { PushInLayer } from '../src/pushInLayer'; describe('getInpoints', () => { - let pushIn: PushIn; + let mockPushInLayer: PushInLayer; beforeEach(() => { setupJSDOM(` - - -
-
-
Layer 0
-
Layer 1
-
Layer 2
-
Layer 3
-
-
- - `); - - pushIn = new PushIn(null); + + +
+
+
Layer 0
+
Layer 1
+
Layer 2
+
Layer 3
+
+
+ + `); + + mockPushInLayer = Object.create(PushInLayer.prototype); + mockPushInLayer['scene'] = {}; }); - afterEach(() => pushIn.destroy()); - it('Should return inpoint + layerDepth by default for first layer', () => { - pushIn['layerDepth'] = 300; + mockPushInLayer['scene']['layerDepth'] = 300; const inpoint = 100; const elem = document.querySelector('#layer-0'); - const result = pushIn['getOutpoints'](elem, inpoint, 0); + const result = mockPushInLayer['getOutpoints'](elem, inpoint); expect(result).toEqual([400]); }); it('Should return data-attribute value if set', () => { - pushIn['layerDepth'] = 300; + mockPushInLayer['scene']['layerDepth'] = 300; const inpoint = 100; const elem = document.querySelector('#layer-1'); - const result = pushIn['getOutpoints'](elem, inpoint, 1); + const result = mockPushInLayer['getOutpoints'](elem, inpoint); expect(result).toEqual([300]); }); it('Should return array of data from data-attribute if set', () => { - pushIn['layerDepth'] = 300; + mockPushInLayer['scene']['layerDepth'] = 300; const inpoint = 100; const elem = document.querySelector('#layer-2'); - const result = pushIn['getOutpoints'](elem, inpoint, 2); + const result = mockPushInLayer['getOutpoints'](elem, inpoint); expect(result).toEqual([300, 500]); }); it('Should generate value based on previous inpoint', () => { - pushIn['layerDepth'] = 300; + mockPushInLayer['scene']['layerDepth'] = 300; const inpoint = 500; const elem = document.querySelector('#layer-3'); - const result = pushIn['getOutpoints'](elem, inpoint, 3); + const result = mockPushInLayer['getOutpoints'](elem, inpoint); expect(result).toEqual([800]); }); diff --git a/test/getScaleValue.spec.ts b/test/getScaleValue.spec.ts index 9c31aa6..728c0f6 100644 --- a/test/getScaleValue.spec.ts +++ b/test/getScaleValue.spec.ts @@ -1,56 +1,59 @@ import { setupJSDOM } from './setup'; +import { PushInLayer } from '../src/pushInLayer'; +import { PushInScene } from '../src/pushInScene'; import { PushIn } from '../src/pushin'; -import { PushInLayer } from '../src/types'; +import { LayerParams } from '../src/types'; describe('getScaleValue', () => { - let pushIn: PushIn; - const layerMock = { - originalScale: 2, - params: { + let layerMock: PushInLayer; + let layerMock2: PushInLayer; + let mockPushInLayer: PushInLayer; + + beforeEach(() => { + setupJSDOM(``); + layerMock = Object.create(PushInLayer.prototype); + layerMock['originalScale'] = 2; + layerMock['params'] = { inpoint: 10, speed: 2, - }, - } as PushInLayer; + }; - const layerMock2 = { - originalScale: 1, - params: { + layerMock2 = Object.create(PushInLayer.prototype); + layerMock2['originalScale'] = 1; + layerMock2['params'] = { inpoint: 150, speed: 100, - }, - } as PushInLayer; + }; - beforeEach(() => { - setupJSDOM(``); - pushIn = new PushIn(null); + mockPushInLayer = Object.create(PushInLayer.prototype); + mockPushInLayer['scene'] = Object.create(PushInScene.prototype); + mockPushInLayer['scene']['pushin'] = {scrollY:0}; }); - afterEach(() => pushIn.destroy()); - it('should return original scale if scroll position and inpoint are the same', () => { - pushIn['scrollY'] = 10; - const result = pushIn['getScaleValue'](layerMock); + mockPushInLayer['scene']['pushin']['scrollY'] = 10; + const result = mockPushInLayer['getScaleValue'](layerMock); expect(result).toEqual(2); }); it('should reduce scale if scrollY is less than inpoint', () => { - pushIn['scrollY'] = 6; - const result = pushIn['getScaleValue'](layerMock); + mockPushInLayer['scene']['pushin']['scrollY'] = 6; + const result = mockPushInLayer['getScaleValue'](layerMock); expect(result).toEqual(1.9992); }); it('should increase scale if scrollY is greater than inpoint', () => { - pushIn['scrollY'] = 20; - const result = pushIn['getScaleValue'](layerMock); + mockPushInLayer['scene']['pushin']['scrollY'] = 20; + const result = mockPushInLayer['getScaleValue'](layerMock); expect(result).toEqual(2.002); }); it('should not return a negative number', () => { - pushIn['scrollY'] = 1; - const result = pushIn['getScaleValue'](layerMock2); + mockPushInLayer['scene']['pushin']['scrollY'] = 1; + const result = mockPushInLayer['getScaleValue'](layerMock2); expect(result).toEqual(0); }); From c93bf2d22c6423c4802d7830427cd7c9e4f94f95 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Thu, 5 May 2022 19:34:01 -0500 Subject: [PATCH 19/32] #69: Refactor test coverage --- src/constants.ts | 2 ++ src/pushinLayer.ts | 8 +++--- src/pushinScene.ts | 3 ++- test/getSpeed.spec.ts | 37 +++++++++++++--------------- test/isActive.spec.ts | 49 ++++++++++++++++++++----------------- test/setBreakpoints.spec.ts | 30 ++++++++++++----------- test/setScale.spec.ts | 16 +++--------- test/setZIndex.spec.ts | 26 ++++++-------------- 8 files changed, 80 insertions(+), 91 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index b6efc02..dabde2c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -10,3 +10,5 @@ export const PUSH_IN_SPEED_DATA_ATTRIBUTE = 'pushinSpeed'; export const PUSH_IN_TO_DATA_ATTRIBUTE = 'pushinTo'; export const PUSH_IN_FROM_DATA_ATTRIBUTE = 'pushinFrom'; + +export const PUSH_IN_DEFAULT_BREAKPOINTS = [768, 1440, 1920]; diff --git a/src/pushinLayer.ts b/src/pushinLayer.ts index 6c2eeb8..810d63e 100644 --- a/src/pushinLayer.ts +++ b/src/pushinLayer.ts @@ -133,9 +133,9 @@ export class PushInLayer { /** * Whether or not a layer should currently be zooming. */ - private isActive(layer: PushInLayer): boolean { - const { inpoint } = layer.params; - const { outpoint } = layer.params; + private isActive(): boolean { + const { inpoint } = this.params; + const { outpoint } = this.params; return ( this.scene.pushin.scrollY >= inpoint && this.scene.pushin.scrollY <= outpoint @@ -202,7 +202,7 @@ export class PushInLayer { opacity = 1; } else if (isLast && this.scene.pushin.scrollY > outpoint) { opacity = 1; - } else if (this.isActive(this)) { + } else if (this.isActive()) { this.setScale(this.element, this.getScaleValue(this)); let inpointDistance = diff --git a/src/pushinScene.ts b/src/pushinScene.ts index f82157d..fb3abf4 100644 --- a/src/pushinScene.ts +++ b/src/pushinScene.ts @@ -1,6 +1,7 @@ import { PUSH_IN_FROM_DATA_ATTRIBUTE, PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE, + PUSH_IN_DEFAULT_BREAKPOINTS, } from './constants'; import { PushInLayer } from './pushInLayer'; import { PushIn } from './pushin'; @@ -51,7 +52,7 @@ export class PushInScene { */ private setBreakpoints(): void { if (this.options?.breakpoints.length === 0) { - this.options.breakpoints = [768, 1440, 1920]; + this.options.breakpoints = [...PUSH_IN_DEFAULT_BREAKPOINTS]; } if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { diff --git a/test/getSpeed.spec.ts b/test/getSpeed.spec.ts index 6850b42..0a63de8 100644 --- a/test/getSpeed.spec.ts +++ b/test/getSpeed.spec.ts @@ -1,45 +1,42 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushInLayer'; import { DEFAULT_SPEED } from '../src/constants'; describe('getSpeed', () => { - let pushIn: PushIn; + let mockPushInLayer: PushInLayer; beforeEach(() => { setupJSDOM(` - - -
-
-
Layer 0
-
Layer 1
-
Layer 2
-
-
- - `); + + +
+
+
Layer 0
+
Layer 1
+
Layer 2
+
+
+ + `); - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); + mockPushInLayer = Object.create(PushInLayer.prototype); }); - afterEach(() => pushIn.destroy()); - it('Should return 8 by default', () => { const elem = document.querySelector('#layer-0'); - const result = pushIn['getSpeed'](elem); + const result = mockPushInLayer['getSpeed'](elem); expect(result).toEqual(DEFAULT_SPEED); }); it('Should return integer value from data-pushin-speed attribute', () => { const elem = document.querySelector('#layer-1'); - const result = pushIn['getSpeed'](elem); + const result = mockPushInLayer['getSpeed'](elem); expect(result).toEqual(50); }); it('Should return default if NaN', () => { const elem = document.querySelector('#layer-2'); - const result = pushIn['getSpeed'](elem); + const result = mockPushInLayer['getSpeed'](elem); expect(result).toEqual(DEFAULT_SPEED); }); }); diff --git a/test/isActive.spec.ts b/test/isActive.spec.ts index e7216ee..a7da330 100644 --- a/test/isActive.spec.ts +++ b/test/isActive.spec.ts @@ -1,55 +1,60 @@ import { setupJSDOM } from './setup'; import { PushIn } from '../src/pushin'; -import { PushInLayer } from '../src/types'; +import { PushInLayer } from '../src/pushInLayer'; +import { PushInScene } from '../src/pushInScene'; +import { LayerParams } from '../src/types'; describe('isActive', () => { - let pushIn: PushIn; - - const layer = { - params: { - inpoint: 10, - outpoint: 20, - }, - } as PushInLayer; + let mockPushInLayer: PushInLayer; beforeEach(() => { setupJSDOM(``); - pushIn = new PushIn(null); + mockPushInLayer = Object.create(PushInLayer.prototype); + + Object.assign( + mockPushInLayer, + { + 'params': { + inpoint: 10, + outpoint: 20 + }, + 'scene': Object.create(PushInScene.prototype), + }); + + mockPushInLayer['scene']['pushin'] = Object.create(PushIn.prototype); }); - afterEach(() => pushIn.destroy()); - it('should be true if screen top is greater than inpoint and less than outpoint', () => { - pushIn['scrollY'] = 15; - const result = pushIn['isActive'](layer); + mockPushInLayer['scene']['pushin']['scrollY'] = 15; + const result = mockPushInLayer['isActive'](); expect(result).toEqual(true); }); it('should be true if screen top is equal to inpoint', () => { - pushIn['scrollY'] = 10; - const result = pushIn['isActive'](layer); + mockPushInLayer['scene']['pushin']['scrollY'] = 10; + const result = mockPushInLayer['isActive'](); expect(result).toEqual(true); }); it('should be true if screen top is equal to outpoint', () => { - pushIn['scrollY'] = 20; - const result = pushIn['isActive'](layer); + mockPushInLayer['scene']['pushin']['scrollY'] = 20; + const result = mockPushInLayer['isActive'](); expect(result).toEqual(true); }); it('should be false if screen top is less than inpoint', () => { - pushIn['scrollY'] = 5; - const result = pushIn['isActive'](layer); + mockPushInLayer['scene']['pushin']['scrollY'] = 5; + const result = mockPushInLayer['isActive'](); expect(result).toEqual(false); }); it('should be false if screen top is greater than outpoint', () => { - pushIn['scrollY'] = 25; - const result = pushIn['isActive'](layer); + mockPushInLayer['scene']['pushin']['scrollY'] = 25; + const result = mockPushInLayer['isActive'](); expect(result).toEqual(false); }); diff --git a/test/setBreakpoints.spec.ts b/test/setBreakpoints.spec.ts index ff9d9c0..ff33d64 100644 --- a/test/setBreakpoints.spec.ts +++ b/test/setBreakpoints.spec.ts @@ -1,8 +1,10 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInScene } from '../src/pushInScene'; +import { SceneOptions } from '../src/types'; +import { PUSH_IN_DEFAULT_BREAKPOINTS } from '../src/constants'; describe('setBreakpoints', () => { - let pushIn: PushIn; + let mockPushInScene: PushInScene; beforeEach(() => { setupJSDOM(` @@ -14,25 +16,25 @@ describe('setBreakpoints', () => { `); - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); - const scene = document.querySelector('.pushin-scene'); - pushIn['scene'] = scene; + mockPushInScene = Object.create(PushInScene.prototype); + mockPushInScene['container'] = document.querySelector('.pushin-scene'); + mockPushInScene['options'] = { + breakpoints: [], + }; }); - afterEach(() => pushIn.destroy()); - it('Should set the default breakpoints', () => { - pushIn['setBreakpoints'](); - const result = pushIn['sceneOptions'].breakpoints; - const expected = [0, 768, 1440, 1920]; + mockPushInScene['setBreakpoints'](); + const result = mockPushInScene['options'].breakpoints; + console.log(PUSH_IN_DEFAULT_BREAKPOINTS); + const expected = [0, ...PUSH_IN_DEFAULT_BREAKPOINTS]; expect(result).toEqual(expected); }); it('Should set the breakpoints provided by data-attributes', () => { - pushIn['scene'].setAttribute('data-pushin-breakpoints', '1,2,3'); - pushIn['setBreakpoints'](); - const result = pushIn['sceneOptions'].breakpoints; + mockPushInScene['container'].setAttribute('data-pushin-breakpoints', '1,2,3'); + mockPushInScene['setBreakpoints'](); + const result = mockPushInScene['options'].breakpoints; const expected = [0, 1, 2, 3]; expect(result).toEqual(expected); }); diff --git a/test/setScale.spec.ts b/test/setScale.spec.ts index 4890bad..561e737 100644 --- a/test/setScale.spec.ts +++ b/test/setScale.spec.ts @@ -1,5 +1,5 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushInLayer'; describe('setScale', () => { beforeEach(() => { @@ -12,18 +12,10 @@ describe('setScale', () => { }); it('should set element scale value', () => { - const instance = new PushIn(null); - + const mockPushInLayer = Object.create(PushInLayer.prototype); const element = document.querySelector('.foo'); - - instance['setScale'](element, 10); - + mockPushInLayer['setScale'](element, 10); const result = element.style.transform; - - try { - expect(result).toEqual('scale(10)'); - } finally { - instance.destroy(); - } + expect(result).toEqual('scale(10)'); }); }); diff --git a/test/setZIndex.spec.ts b/test/setZIndex.spec.ts index a48c86d..495ae82 100644 --- a/test/setZIndex.spec.ts +++ b/test/setZIndex.spec.ts @@ -1,8 +1,8 @@ import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushInLayer'; describe('setZIndex', () => { - let pushIn: PushIn; + let mockPushInLayer: PushInLayer; beforeEach(() => { setupJSDOM(` @@ -18,24 +18,14 @@ describe('setZIndex', () => { `); - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); + mockPushInLayer = Object.create(PushInLayer.prototype); + mockPushInLayer['element'] = document.querySelector('#layer-1'); + mockPushInLayer['index'] = 1; }); - afterEach(() => pushIn.destroy()); - it('Should return the difference between the total number of layers and the current layer index', () => { - const mockLayer: any = { - element: { - style: { - zIndex: null, - }, - }, - index: 1, - }; - - pushIn['setZIndex'](mockLayer, 10); - const result = mockLayer.element.style.zIndex; - expect(result).toEqual('9'); + mockPushInLayer['setZIndex'](3); + const result = mockPushInLayer['element'].style.zIndex; + expect(result).toEqual('2'); }); }); From a264a4a5a972c90be21fce3a000a5b31fe25a41e Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 8 May 2022 18:31:44 -0500 Subject: [PATCH 20/32] #69: All unit tests passing --- test/setLayerStyle.spec.ts | 143 ++++++++++++++++++----------------- test/setScrollLength.spec.ts | 61 ++++++++++----- 2 files changed, 113 insertions(+), 91 deletions(-) diff --git a/test/setLayerStyle.spec.ts b/test/setLayerStyle.spec.ts index 8927c23..a7b9bf9 100644 --- a/test/setLayerStyle.spec.ts +++ b/test/setLayerStyle.spec.ts @@ -1,90 +1,97 @@ import { setupJSDOM } from './setup'; +import { PushInLayer } from '../src/pushInLayer'; import { PushIn } from '../src/pushin'; +import { PushInScene } from '../src/pushInScene'; +import { LayerParams } from '../src/types'; describe('setLayerStyle', () => { - let pushIn: PushIn; + let mockPushInLayer: PushInLayer; + let element: HTMLElement; beforeEach(() => { setupJSDOM(` -
+
Lorem Ipsum
-
- Dolor sit amet -
-
- Hello World -
`); - const layers = [ + element = document.querySelector('.pushin-layer'); + + const mockScene = Object.create(PushInScene.prototype); + Object.assign( + mockScene, + { + transitionLength: 200, + } + ); + + mockPushInLayer = Object.create(PushInLayer.prototype); + Object.assign( + mockPushInLayer, { - element: document.querySelector('.demo-layer-1'), + element: document.querySelector('.pushin-layer'), index: 0, - originalScale: 1, - params: { + 'params': { inpoint: 200, outpoint: 500, - speed: 8, }, - }, + 'scene': mockScene, + }); + + const mockPushIn = Object.create(PushIn.prototype); + Object.assign( + mockPushIn, { - element: document.querySelector('.demo-layer-2'), - index: 1, - originalScale: 1, - params: { - inpoint: 500, - outpoint: 800, - speed: 8, - }, - }, + scrollY: 0, + } + ); + + Object.assign( + mockPushInLayer['scene'], { - element: document.querySelector('.demo-layer-3'), - index: 2, - originalScale: 1, - params: { - inpoint: 800, - outpoint: 1200, - speed: 8, - }, - }, - ]; - - pushIn = new PushIn(null); - Object.assign(pushIn, { - isActive: () => true, - layers, - transitionLength: 200, - }); + pushin: mockPushIn, + layers: [ + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype) + ], + } + ); + + // stub methods + Object.assign( + mockPushInLayer, + { + isActive: () => true, + setScale: () => null, + getScaleValue: () => null, + } + ); }); - afterEach(() => pushIn.destroy()); - it('should set opacity to 1 if its the first layer and the scroll position is before its inpoint', () => { - pushIn['scrollY'] = 10; - const element = document.querySelector('.demo-layer-1'); - pushIn['setLayerStyle'](pushIn['layers'][0]); + mockPushInLayer['scene']['pushin']['scrollY'] = 10; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; expect(result).toEqual('1'); }); it('should set opacity to 1 if its the first layer and it is active', () => { - pushIn['scrollY'] = 205; - const element = document.querySelector('.demo-layer-1'); - pushIn['setLayerStyle'](pushIn['layers'][0]); + mockPushInLayer['scene']['pushin']['scrollY'] = 205; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; expect(result).toEqual('1'); }); it('should set opacity to 1 if its the last layer and the scroll position is after its outpoint', () => { - pushIn['scrollY'] = 1300; - const element = document.querySelector('.demo-layer-3'); - pushIn['setLayerStyle'](pushIn['layers'][2]); + mockPushInLayer['scene']['pushin']['scrollY'] = 600; + mockPushInLayer['index'] = 2; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; @@ -92,9 +99,9 @@ describe('setLayerStyle', () => { }); it('should set opacity to 1 if its the last layer and it is active', () => { - pushIn['scrollY'] = 1195; - const element = document.querySelector('.demo-layer-3'); - pushIn['setLayerStyle'](pushIn['layers'][2]); + mockPushInLayer['scene']['pushin']['scrollY'] = 450; + mockPushInLayer['index'] = 2; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; @@ -102,10 +109,9 @@ describe('setLayerStyle', () => { }); it('should set opacity to 0 if its a middle layer and scroll position is exactly equal to its inpoint', () => { - pushIn['scrollY'] = 500; - const element = document.querySelector('.demo-layer-2'); - - pushIn['setLayerStyle'](pushIn['layers'][1]); + mockPushInLayer['scene']['pushin']['scrollY'] = 200; + mockPushInLayer['index'] = 1; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; @@ -113,10 +119,9 @@ describe('setLayerStyle', () => { }); it('should set opacity to 0.5 if its a middle layer and scroll position is 100px from its inpoint', () => { - pushIn['scrollY'] = 600; - const element = document.querySelector('.demo-layer-2'); - - pushIn['setLayerStyle'](pushIn['layers'][1]); + mockPushInLayer['scene']['pushin']['scrollY'] = 300; + mockPushInLayer['index'] = 1; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; @@ -124,10 +129,9 @@ describe('setLayerStyle', () => { }); it('should set opacity to 0 if its a middle layer and scroll position is exactly equal to its outpoint', () => { - pushIn['scrollY'] = 800; - const element = document.querySelector('.demo-layer-2'); - - pushIn['setLayerStyle'](pushIn['layers'][1]); + mockPushInLayer['scene']['pushin']['scrollY'] = 500; + mockPushInLayer['index'] = 1; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; @@ -135,10 +139,9 @@ describe('setLayerStyle', () => { }); it('should set opacity to 0.5 if its a middle layer and scroll position is 100px from its outpoint', () => { - pushIn['scrollY'] = 700; - const element = document.querySelector('.demo-layer-2'); - - pushIn['setLayerStyle'](pushIn['layers'][1]); + mockPushInLayer['scene']['pushin']['scrollY'] = 400; + mockPushInLayer['index'] = 1; + mockPushInLayer['setLayerStyle'](); const result = element.style.opacity; diff --git a/test/setScrollLength.spec.ts b/test/setScrollLength.spec.ts index 55d7756..536cb08 100644 --- a/test/setScrollLength.spec.ts +++ b/test/setScrollLength.spec.ts @@ -1,8 +1,11 @@ import { setupJSDOM } from './setup'; import { PushIn } from '../src/pushin'; +import { PushInLayer } from '../src/pushInLayer'; +import { PushInScene } from '../src/pushInScene'; describe('setScrollLength', () => { - let pushIn: PushIn; + let mockPushIn: PushIn; + let container: HTMLElement; beforeEach(() => { setupJSDOM(` @@ -12,40 +15,56 @@ describe('setScrollLength', () => { `); - const container = document.querySelector('.pushin'); - pushIn = new PushIn(container); + container = document.querySelector('.pushin'); - (pushIn as any).layers = [1, 2, 3]; - pushIn['speedDelta'] = 100; - pushIn['layerDepth'] = 100; - pushIn['transitionLength'] = 100; - }); + const mockScene = Object.create(PushInScene.prototype); + Object.assign( + mockScene, + { + speedDelta: 100, + layerDepth: 100, + transitionLength: 100, + } + ); - afterEach(() => pushIn.destroy()); + mockPushIn = Object.create(PushIn.prototype); + Object.assign( + mockPushIn, + { + container, + layers: [ + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype), + ], + scene: mockScene + } + ); + }); it('Should set the container height to its original value if it is higher than calculated value', () => { - pushIn['setScrollLength'](); - const result = pushIn['container'].style.height; + mockPushIn['setScrollLength'](); + const result = container.style.height; expect(result).toEqual('500px'); }); it('Should calculate container height based on layerDepth and transitionLength properties', () => { - pushIn['speedDelta'] = 0; - pushIn['layerDepth'] = 200; - pushIn['transitionLength'] = 200; + mockPushIn['scene']['speedDelta'] = 0; + mockPushIn['scene']['layerDepth'] = 200; + mockPushIn['scene']['transitionLength'] = 200; - pushIn['setScrollLength'](); - const result = pushIn['container'].style.height; + mockPushIn['setScrollLength'](); + const result = container.style.height; expect(result).toEqual('1200px'); }); it('Should reduce container height to account for overlapping transition length', () => { - pushIn['speedDelta'] = 100; - pushIn['layerDepth'] = 200; - pushIn['transitionLength'] = 200; + mockPushIn['scene']['speedDelta'] = 100; + mockPushIn['scene']['layerDepth'] = 200; + mockPushIn['scene']['transitionLength'] = 200; - pushIn['setScrollLength'](); - const result = pushIn['container'].style.height; + mockPushIn['setScrollLength'](); + const result = container.style.height; expect(result).toEqual('1000px'); }); }); From acd90da031dec311718ca885e17dd174b3fa2889 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 8 May 2022 18:38:06 -0500 Subject: [PATCH 21/32] change filename capitalization --- src/{pushinLayer.ts => pushInLayer.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{pushinLayer.ts => pushInLayer.ts} (100%) diff --git a/src/pushinLayer.ts b/src/pushInLayer.ts similarity index 100% rename from src/pushinLayer.ts rename to src/pushInLayer.ts From 7dc8b921e174f1fd4b750397247a8ee25d6ae5cc Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 8 May 2022 18:38:34 -0500 Subject: [PATCH 22/32] change filename capitalization --- src/{pushinScene.ts => pushInScene.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{pushinScene.ts => pushInScene.ts} (100%) diff --git a/src/pushinScene.ts b/src/pushInScene.ts similarity index 100% rename from src/pushinScene.ts rename to src/pushInScene.ts From 3b7e9cd4692c962f2f3e9f388adb5de22fbc0a64 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 8 May 2022 20:35:17 -0500 Subject: [PATCH 23/32] #69: Move tests into subfolders --- jest.config.ts | 2 +- src/pushInScene.ts | 2 +- src/pushin.ts | 8 ++++---- test/{ => pushIn}/destroy.spec.ts | 4 ++-- test/{ => pushIn}/setScrollLength.spec.ts | 18 +++++++++--------- .../{ => pushInLayer}/getElementScaleX.spec.ts | 8 +++----- test/{ => pushInLayer}/getInpoints.spec.ts | 6 +++--- test/{ => pushInLayer}/getOutpoints.spec.ts | 6 +++--- test/{ => pushInLayer}/getScaleValue.spec.ts | 10 +++++----- test/{ => pushInLayer}/getSpeed.spec.ts | 6 +++--- test/{ => pushInLayer}/isActive.spec.ts | 10 +++++----- test/{ => pushInLayer}/setLayerStyle.spec.ts | 10 +++++----- test/{ => pushInLayer}/setScale.spec.ts | 4 ++-- test/{ => pushInLayer}/setZIndex.spec.ts | 4 ++-- .../getBreakpointIndex.spec.ts | 4 ++-- test/{ => pushInScene}/getLayers.spec.ts | 8 ++++---- test/{ => pushInScene}/setBreakpoints.spec.ts | 8 ++++---- 17 files changed, 58 insertions(+), 60 deletions(-) rename test/{ => pushIn}/destroy.spec.ts (89%) rename test/{ => pushIn}/setScrollLength.spec.ts (90%) rename test/{ => pushInLayer}/getElementScaleX.spec.ts (81%) rename test/{ => pushInLayer}/getInpoints.spec.ts (93%) rename test/{ => pushInLayer}/getOutpoints.spec.ts (93%) rename test/{ => pushInLayer}/getScaleValue.spec.ts (87%) rename test/{ => pushInLayer}/getSpeed.spec.ts (90%) rename test/{ => pushInLayer}/isActive.spec.ts (87%) rename test/{ => pushInLayer}/setLayerStyle.spec.ts (94%) rename test/{ => pushInLayer}/setScale.spec.ts (85%) rename test/{ => pushInLayer}/setZIndex.spec.ts (91%) rename test/{ => pushInScene}/getBreakpointIndex.spec.ts (89%) rename test/{ => pushInScene}/getLayers.spec.ts (88%) rename test/{ => pushInScene}/setBreakpoints.spec.ts (84%) diff --git a/jest.config.ts b/jest.config.ts index 4f879ed..f62cbf4 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -54,7 +54,7 @@ const config: Config.InitialOptions = { /** * The glob patterns Jest uses to detect test files. */ - testMatch: ['/test/*.spec.ts'], + testMatch: ['/test/**/*.spec.ts'], /** * Indicates whether each individual test should be reported during the run. diff --git a/src/pushInScene.ts b/src/pushInScene.ts index fb3abf4..210950a 100644 --- a/src/pushInScene.ts +++ b/src/pushInScene.ts @@ -102,7 +102,7 @@ export class PushInScene { } getInpoints(): number[] { - let inpoints = []; + let inpoints = [this.getTop()]; if (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { const pushInFrom = ( diff --git a/src/pushin.ts b/src/pushin.ts index ad4a3ea..f19418d 100644 --- a/src/pushin.ts +++ b/src/pushin.ts @@ -111,7 +111,7 @@ export class PushIn { clearTimeout(resizeTimeout); resizeTimeout = window.setTimeout(() => { - this.layers.forEach(layer => layer.resetLayerParams()); + this.scene.layers.forEach(layer => layer.resetLayerParams()); this.setScrollLength(); this.toggleLayers(); }, 300); @@ -135,7 +135,7 @@ export class PushIn { * Show or hide layers and set their scale, depending on if active. */ private toggleLayers(): void { - this.layers.forEach(layer => layer.setLayerStyle()); + this.scene.layers.forEach(layer => layer.setLayerStyle()); } /** @@ -153,9 +153,9 @@ export class PushIn { '' ); - const transitions = (this.layers.length - 1) * this.scene.speedDelta; + const transitions = (this.scene.layers.length - 1) * this.scene.speedDelta; const scrollLength = - this.layers.length * + this.scene.layers.length * (this.scene.layerDepth + this.scene.transitionLength); this.container.style.height = `${Math.max( diff --git a/test/destroy.spec.ts b/test/pushIn/destroy.spec.ts similarity index 89% rename from test/destroy.spec.ts rename to test/pushIn/destroy.spec.ts index d941d16..a969fb8 100644 --- a/test/destroy.spec.ts +++ b/test/pushIn/destroy.spec.ts @@ -1,5 +1,5 @@ -import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; +import { setupJSDOM } from '../setup'; +import { PushIn } from '../../src/pushin'; describe('destroy', () => { let textContent: string; diff --git a/test/setScrollLength.spec.ts b/test/pushIn/setScrollLength.spec.ts similarity index 90% rename from test/setScrollLength.spec.ts rename to test/pushIn/setScrollLength.spec.ts index 536cb08..72c39d6 100644 --- a/test/setScrollLength.spec.ts +++ b/test/pushIn/setScrollLength.spec.ts @@ -1,7 +1,7 @@ -import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; -import { PushInLayer } from '../src/pushInLayer'; -import { PushInScene } from '../src/pushInScene'; +import { setupJSDOM } from '../setup'; +import { PushIn } from '../../src/pushin'; +import { PushInLayer } from '../../src/pushInLayer'; +import { PushInScene } from '../../src/pushInScene'; describe('setScrollLength', () => { let mockPushIn: PushIn; @@ -24,6 +24,11 @@ describe('setScrollLength', () => { speedDelta: 100, layerDepth: 100, transitionLength: 100, + layers: [ + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype), + Object.create(PushInLayer.prototype), + ] } ); @@ -32,11 +37,6 @@ describe('setScrollLength', () => { mockPushIn, { container, - layers: [ - Object.create(PushInLayer.prototype), - Object.create(PushInLayer.prototype), - Object.create(PushInLayer.prototype), - ], scene: mockScene } ); diff --git a/test/getElementScaleX.spec.ts b/test/pushInLayer/getElementScaleX.spec.ts similarity index 81% rename from test/getElementScaleX.spec.ts rename to test/pushInLayer/getElementScaleX.spec.ts index 7da41c5..61844c0 100644 --- a/test/getElementScaleX.spec.ts +++ b/test/pushInLayer/getElementScaleX.spec.ts @@ -1,10 +1,10 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; describe('getElementScaleX', () => { let element: HTMLElement; let mockPushInLayer: PushInLayer; - jest.mock('../src/pushInLayer', () => jest.fn()); + jest.mock('../../src/pushInLayer', () => jest.fn()); beforeEach(() => { setupJSDOM(` @@ -19,8 +19,6 @@ describe('getElementScaleX', () => { mockPushInLayer['element'] = element; }); - // afterEach(() => pushInLayer.destroy()); - it('Should return default element scale if never altered', () => { const result = mockPushInLayer['getElementScaleX'](element); expect(result).toEqual(1); diff --git a/test/getInpoints.spec.ts b/test/pushInLayer/getInpoints.spec.ts similarity index 93% rename from test/getInpoints.spec.ts rename to test/pushInLayer/getInpoints.spec.ts index 648b79a..1e257f8 100644 --- a/test/getInpoints.spec.ts +++ b/test/pushInLayer/getInpoints.spec.ts @@ -1,6 +1,6 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; -import { PushInScene } from '../src/pushInScene'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; +import { PushInScene } from '../../src/pushInScene'; describe('getInpoints', () => { let mockPushInLayer: PushInLayer; diff --git a/test/getOutpoints.spec.ts b/test/pushInLayer/getOutpoints.spec.ts similarity index 93% rename from test/getOutpoints.spec.ts rename to test/pushInLayer/getOutpoints.spec.ts index f79cf6b..5a4a5a8 100644 --- a/test/getOutpoints.spec.ts +++ b/test/pushInLayer/getOutpoints.spec.ts @@ -1,6 +1,6 @@ -import { setupJSDOM } from './setup'; -import { PushInScene } from '../src/pushInScene'; -import { PushInLayer } from '../src/pushInLayer'; +import { setupJSDOM } from '../setup'; +import { PushInScene } from '../../src/pushInScene'; +import { PushInLayer } from '../../src/pushInLayer'; describe('getInpoints', () => { let mockPushInLayer: PushInLayer; diff --git a/test/getScaleValue.spec.ts b/test/pushInLayer/getScaleValue.spec.ts similarity index 87% rename from test/getScaleValue.spec.ts rename to test/pushInLayer/getScaleValue.spec.ts index 728c0f6..217abc1 100644 --- a/test/getScaleValue.spec.ts +++ b/test/pushInLayer/getScaleValue.spec.ts @@ -1,8 +1,8 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; -import { PushInScene } from '../src/pushInScene'; -import { PushIn } from '../src/pushin'; -import { LayerParams } from '../src/types'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; +import { PushInScene } from '../../src/pushInScene'; +import { PushIn } from '../../src/pushin'; +import { LayerParams } from '../../src/types'; describe('getScaleValue', () => { let layerMock: PushInLayer; diff --git a/test/getSpeed.spec.ts b/test/pushInLayer/getSpeed.spec.ts similarity index 90% rename from test/getSpeed.spec.ts rename to test/pushInLayer/getSpeed.spec.ts index 0a63de8..397503b 100644 --- a/test/getSpeed.spec.ts +++ b/test/pushInLayer/getSpeed.spec.ts @@ -1,6 +1,6 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; -import { DEFAULT_SPEED } from '../src/constants'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; +import { DEFAULT_SPEED } from '../../src/constants'; describe('getSpeed', () => { let mockPushInLayer: PushInLayer; diff --git a/test/isActive.spec.ts b/test/pushInLayer/isActive.spec.ts similarity index 87% rename from test/isActive.spec.ts rename to test/pushInLayer/isActive.spec.ts index a7da330..db92cc7 100644 --- a/test/isActive.spec.ts +++ b/test/pushInLayer/isActive.spec.ts @@ -1,8 +1,8 @@ -import { setupJSDOM } from './setup'; -import { PushIn } from '../src/pushin'; -import { PushInLayer } from '../src/pushInLayer'; -import { PushInScene } from '../src/pushInScene'; -import { LayerParams } from '../src/types'; +import { setupJSDOM } from '../setup'; +import { PushIn } from '../../src/pushin'; +import { PushInLayer } from '../../src/pushInLayer'; +import { PushInScene } from '../../src/pushInScene'; +import { LayerParams } from '../../src/types'; describe('isActive', () => { let mockPushInLayer: PushInLayer; diff --git a/test/setLayerStyle.spec.ts b/test/pushInLayer/setLayerStyle.spec.ts similarity index 94% rename from test/setLayerStyle.spec.ts rename to test/pushInLayer/setLayerStyle.spec.ts index a7b9bf9..d43dc2a 100644 --- a/test/setLayerStyle.spec.ts +++ b/test/pushInLayer/setLayerStyle.spec.ts @@ -1,8 +1,8 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; -import { PushIn } from '../src/pushin'; -import { PushInScene } from '../src/pushInScene'; -import { LayerParams } from '../src/types'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; +import { PushIn } from '../../src/pushin'; +import { PushInScene } from '../../src/pushInScene'; +import { LayerParams } from '../../src/types'; describe('setLayerStyle', () => { let mockPushInLayer: PushInLayer; diff --git a/test/setScale.spec.ts b/test/pushInLayer/setScale.spec.ts similarity index 85% rename from test/setScale.spec.ts rename to test/pushInLayer/setScale.spec.ts index 561e737..2f49250 100644 --- a/test/setScale.spec.ts +++ b/test/pushInLayer/setScale.spec.ts @@ -1,5 +1,5 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; describe('setScale', () => { beforeEach(() => { diff --git a/test/setZIndex.spec.ts b/test/pushInLayer/setZIndex.spec.ts similarity index 91% rename from test/setZIndex.spec.ts rename to test/pushInLayer/setZIndex.spec.ts index 495ae82..6ed960e 100644 --- a/test/setZIndex.spec.ts +++ b/test/pushInLayer/setZIndex.spec.ts @@ -1,5 +1,5 @@ -import { setupJSDOM } from './setup'; -import { PushInLayer } from '../src/pushInLayer'; +import { setupJSDOM } from '../setup'; +import { PushInLayer } from '../../src/pushInLayer'; describe('setZIndex', () => { let mockPushInLayer: PushInLayer; diff --git a/test/getBreakpointIndex.spec.ts b/test/pushInScene/getBreakpointIndex.spec.ts similarity index 89% rename from test/getBreakpointIndex.spec.ts rename to test/pushInScene/getBreakpointIndex.spec.ts index 1d7184f..d137db4 100644 --- a/test/getBreakpointIndex.spec.ts +++ b/test/pushInScene/getBreakpointIndex.spec.ts @@ -1,5 +1,5 @@ -import { setupJSDOM } from './setup'; -import { PushInScene } from '../src/pushinScene'; +import { setupJSDOM } from '../setup'; +import { PushInScene } from '../../src/pushInScene'; describe('getBreakpointIndex', () => { beforeEach(() => { diff --git a/test/getLayers.spec.ts b/test/pushInScene/getLayers.spec.ts similarity index 88% rename from test/getLayers.spec.ts rename to test/pushInScene/getLayers.spec.ts index 4d9c061..485ce45 100644 --- a/test/getLayers.spec.ts +++ b/test/pushInScene/getLayers.spec.ts @@ -1,7 +1,7 @@ -import { setupJSDOM } from './setup'; -import { PushInScene } from '../src/pushInScene'; -import { PushInLayer } from '../src/pushInLayer'; -jest.mock('../src/pushInLayer'); +import { setupJSDOM } from '../setup'; +import { PushInScene } from '../../src/pushInScene'; +import { PushInLayer } from '../../src/pushInLayer'; +jest.mock('../../src/pushInLayer'); describe('getLayers', () => { let mockPushInScene: PushInScene; diff --git a/test/setBreakpoints.spec.ts b/test/pushInScene/setBreakpoints.spec.ts similarity index 84% rename from test/setBreakpoints.spec.ts rename to test/pushInScene/setBreakpoints.spec.ts index ff33d64..0229a57 100644 --- a/test/setBreakpoints.spec.ts +++ b/test/pushInScene/setBreakpoints.spec.ts @@ -1,7 +1,7 @@ -import { setupJSDOM } from './setup'; -import { PushInScene } from '../src/pushInScene'; -import { SceneOptions } from '../src/types'; -import { PUSH_IN_DEFAULT_BREAKPOINTS } from '../src/constants'; +import { setupJSDOM } from '../setup'; +import { PushInScene } from '../../src/pushInScene'; +import { SceneOptions } from '../../src/types'; +import { PUSH_IN_DEFAULT_BREAKPOINTS } from '../../src/constants'; describe('setBreakpoints', () => { let mockPushInScene: PushInScene; From c989a767b8091c1a845be9e4df1adb117055baab Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Sun, 8 May 2022 20:45:13 -0500 Subject: [PATCH 24/32] #69: Fix class declaration and destroy method implementation --- dist/esm/pushin.d.ts | 85 ++------------------------------------------ src/pushInScene.ts | 3 +- src/pushin.ts | 2 +- 3 files changed, 5 insertions(+), 85 deletions(-) diff --git a/dist/esm/pushin.d.ts b/dist/esm/pushin.d.ts index 83d897d..4beec98 100644 --- a/dist/esm/pushin.d.ts +++ b/dist/esm/pushin.d.ts @@ -10,18 +10,12 @@ export declare class PushIn { private scene; private pushinDebug?; private layerOptions; - private sceneOptions; - private scrollY; - private scrollEnd; - private touchStart; - private pageHeight; + public sceneOptions; + public scrollY; private readonly layers; private readonly debug; - private speedDelta; - private transitionLength; - private layerDepth; private lastAnimationFrameId; - private readonly cleanupFns; + public cleanupFns; constructor(container: HTMLElement, options?: PushInOptions); /** * Initialize the object to start everything up. @@ -38,54 +32,10 @@ export declare class PushIn { * Otherwise default to 0. */ private getScrollY; - /** - * Get the "scene" element from the DOM. - * If it doesn't exist, make one. - */ - private addScene; - /** - * Set breakpoints for responsive design settings. - */ - private setBreakpoints; - /** - * Find all layers on the page and store them with their parameters - */ - private getLayers; - /** - * Get all inpoints for the layer. - */ - private getInpoints; - /** - * Get all outpoints for the layer. - */ - private getOutpoints; - /** - * Get the push-in speed for the layer. - */ - private getSpeed; - /** - * Get the array index of the current window breakpoint. - */ - private getBreakpointIndex; - /** - * Set the z-index of each layer so they overlap correctly. - */ - private setZIndex; /** * Bind event listeners to watch for page load and user interaction. */ bindEvents(): void; - /** - * Reset all the layer parameters. - * - * This is used if the window is resized - * and things need to be recalculated. - */ - private resetLayerParams; - /** - * Get the initial scale of the element at time of DOM load. - */ - private getElementScaleX; /** * Animation effect, mimicking a camera dolly on the webpage. */ @@ -94,35 +44,6 @@ export declare class PushIn { * Show or hide layers and set their scale, depending on if active. */ private toggleLayers; - /** - * Whether or not a layer should currently be zooming. - */ - private isActive; - /** - * Get the current inpoint for a layer, - * depending on window breakpoint. - */ - private getInpoint; - /** - * Get the current outpoint for a layer, - * depending on window breakpoint. - */ - private getOutpoint; - /** - * Get the scaleX value for the layer. - */ - private getScaleValue; - /** - * Set element scale. - */ - private setScale; - /** - * Set CSS styles to control the effect on each layer. - * - * This will control the scale and opacity of the layer - * as the user scrolls. - */ - private setLayerStyle; /** * Set the default container height based on a few factors: * 1. Number of layers present diff --git a/src/pushInScene.ts b/src/pushInScene.ts index 210950a..dc3f54c 100644 --- a/src/pushInScene.ts +++ b/src/pushInScene.ts @@ -10,7 +10,6 @@ import { LayerOptions, SceneOptions } from './types'; export class PushInScene { private container: HTMLElement; - private readonly cleanupFns: VoidFunction[] = []; public layers: PushInLayer[]; public speedDelta: number; public transitionLength: number; @@ -30,7 +29,7 @@ export class PushInScene { this.container.innerHTML = this.pushin.container.innerHTML; this.pushin.container.innerHTML = ''; this.pushin.container.appendChild(this.container); - this.cleanupFns.push(() => { + this.pushin.cleanupFns.push(() => { this.pushin.container.innerHTML = this.container.innerHTML; }); } diff --git a/src/pushin.ts b/src/pushin.ts index f19418d..c8b823b 100644 --- a/src/pushin.ts +++ b/src/pushin.ts @@ -20,7 +20,7 @@ export class PushIn { private readonly debug: boolean; private lastAnimationFrameId = -1; - private readonly cleanupFns: VoidFunction[] = []; + public cleanupFns: VoidFunction[] = []; constructor(public container: HTMLElement, options?: PushInOptions) { this.debug = options?.debug ?? false; From c9c39d5052e53ecab3a754ff943a59841dd864b3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 04:18:14 +0000 Subject: [PATCH 25/32] Bump lint-staged from 12.3.8 to 12.4.1 Bumps [lint-staged](https://github.com/okonet/lint-staged) from 12.3.8 to 12.4.1. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v12.3.8...v12.4.1) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..0ad72c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9202,9 +9202,9 @@ "dev": true }, "node_modules/lint-staged": { - "version": "12.3.8", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.8.tgz", - "integrity": "sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==", + "version": "12.4.1", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.1.tgz", + "integrity": "sha512-PTXgzpflrQ+pODQTG116QNB+Q6uUTDg5B5HqGvNhoQSGt8Qy+MA/6zSnR8n38+sxP5TapzeQGTvoKni0KRS8Vg==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", @@ -19225,9 +19225,9 @@ "dev": true }, "lint-staged": { - "version": "12.3.8", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.8.tgz", - "integrity": "sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ==", + "version": "12.4.1", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.4.1.tgz", + "integrity": "sha512-PTXgzpflrQ+pODQTG116QNB+Q6uUTDg5B5HqGvNhoQSGt8Qy+MA/6zSnR8n38+sxP5TapzeQGTvoKni0KRS8Vg==", "dev": true, "requires": { "cli-truncate": "^3.1.0", From eab8f4bbe48a08b5eed70847fe0fb076e107f4b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 04:18:23 +0000 Subject: [PATCH 26/32] Bump @types/jest from 27.4.1 to 27.5.0 Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 27.4.1 to 27.5.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..68959ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2745,9 +2745,9 @@ } }, "node_modules/@types/jest": { - "version": "27.4.1", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.1.tgz", - "integrity": "sha512-23iPJADSmicDVrWk+HT58LMJtzLAnB2AgIzplQuq/bSrGaxCrlvRFjGbXmamnnk/mAmCdLStiGqggu28ocUyiw==", + "version": "27.5.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz", + "integrity": "sha512-9RBFx7r4k+msyj/arpfaa0WOOEcaAZNmN+j80KFbFCoSqCJGHTz7YMAMGQW9Xmqm5w6l5c25vbSjMwlikJi5+g==", "dev": true, "dependencies": { "jest-matcher-utils": "^27.0.0", @@ -14828,9 +14828,9 @@ } }, "@types/jest": { - "version": "27.4.1", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.1.tgz", - "integrity": "sha512-23iPJADSmicDVrWk+HT58LMJtzLAnB2AgIzplQuq/bSrGaxCrlvRFjGbXmamnnk/mAmCdLStiGqggu28ocUyiw==", + "version": "27.5.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.5.0.tgz", + "integrity": "sha512-9RBFx7r4k+msyj/arpfaa0WOOEcaAZNmN+j80KFbFCoSqCJGHTz7YMAMGQW9Xmqm5w6l5c25vbSjMwlikJi5+g==", "dev": true, "requires": { "jest-matcher-utils": "^27.0.0", From 2df1065b89d585859caad7dbb6861782a1fe6ee2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 04:18:36 +0000 Subject: [PATCH 27/32] Bump eslint from 8.13.0 to 8.15.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.13.0 to 8.15.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.13.0...v8.15.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 110 ++++++++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..a52c85d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1583,18 +1583,19 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.2.1", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.3.tgz", + "integrity": "sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==", "dev": true, - "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", + "espree": "^9.3.2", "globals": "^13.9.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { @@ -1602,9 +1603,10 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.13.0", + "version": "13.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz", + "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==", "dev": true, - "license": "MIT", "dependencies": { "type-fest": "^0.20.2" }, @@ -1617,8 +1619,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, - "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, @@ -3481,9 +3484,10 @@ } }, "node_modules/acorn": { - "version": "8.7.0", + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", + "integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==", "dev": true, - "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -3521,8 +3525,9 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, - "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -3681,8 +3686,9 @@ }, "node_modules/argparse": { "version": "2.0.1", - "dev": true, - "license": "Python-2.0" + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "node_modules/array-flatten": { "version": "2.1.2", @@ -5280,11 +5286,12 @@ } }, "node_modules/eslint": { - "version": "8.13.0", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz", + "integrity": "sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==", "dev": true, - "license": "MIT", "dependencies": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.3", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -5295,7 +5302,7 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.3.2", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -5311,7 +5318,7 @@ "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", @@ -5612,12 +5619,13 @@ } }, "node_modules/espree": { - "version": "9.3.1", + "version": "9.3.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.2.tgz", + "integrity": "sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.7.1", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -6523,8 +6531,9 @@ }, "node_modules/import-fresh": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, - "license": "MIT", "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -9035,8 +9044,9 @@ }, "node_modules/js-yaml": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, @@ -10044,8 +10054,9 @@ }, "node_modules/parent-module": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, - "license": "MIT", "dependencies": { "callsites": "^3.0.0" }, @@ -10833,8 +10844,9 @@ }, "node_modules/resolve-from": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -13947,22 +13959,26 @@ "dev": true }, "@eslint/eslintrc": { - "version": "1.2.1", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.3.tgz", + "integrity": "sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", + "espree": "^9.3.2", "globals": "^13.9.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "dependencies": { "globals": { - "version": "13.13.0", + "version": "13.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.14.0.tgz", + "integrity": "sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -13970,6 +13986,8 @@ }, "type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true } } @@ -15334,7 +15352,9 @@ } }, "acorn": { - "version": "8.7.0", + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", + "integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==", "dev": true }, "acorn-globals": { @@ -15358,6 +15378,8 @@ }, "acorn-jsx": { "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "requires": {} }, @@ -15456,6 +15478,8 @@ }, "argparse": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, "array-flatten": { @@ -16532,10 +16556,12 @@ } }, "eslint": { - "version": "8.13.0", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.15.0.tgz", + "integrity": "sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.3", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -16546,7 +16572,7 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.3.2", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -16562,7 +16588,7 @@ "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", @@ -16747,11 +16773,13 @@ "dev": true }, "espree": { - "version": "9.3.1", + "version": "9.3.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.2.tgz", + "integrity": "sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==", "dev": true, "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.7.1", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" } }, @@ -17335,6 +17363,8 @@ }, "import-fresh": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -19111,6 +19141,8 @@ }, "js-yaml": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -19760,6 +19792,8 @@ }, "parent-module": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "requires": { "callsites": "^3.0.0" @@ -20286,6 +20320,8 @@ }, "resolve-from": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "resolve.exports": { From 9ea956bd582b02a306c2aa61d778b47e74d9c2fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 04:18:47 +0000 Subject: [PATCH 28/32] Bump rollup from 2.70.2 to 2.72.1 Bumps [rollup](https://github.com/rollup/rollup) from 2.70.2 to 2.72.1. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v2.70.2...v2.72.1) --- updated-dependencies: - dependency-name: rollup dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..6b6814b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "prettier": "^2.6.1", "pug": "^3.0.2", "pug-loader": "^2.4.0", - "rollup": "2.70.2", + "rollup": "2.72.1", "rollup-plugin-copy": "3.4.0", "rollup-plugin-terser": "^7.0.2", "style-loader": "^3.3.1", @@ -10897,9 +10897,9 @@ } }, "node_modules/rollup": { - "version": "2.70.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", - "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", + "version": "2.72.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.72.1.tgz", + "integrity": "sha512-NTc5UGy/NWFGpSqF1lFY8z9Adri6uhyMLI6LvPAXdBKoPRFhIIiBUpt+Qg2awixqO3xvzSijjhnb4+QEZwJmxA==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -20322,9 +20322,9 @@ } }, "rollup": { - "version": "2.70.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.70.2.tgz", - "integrity": "sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==", + "version": "2.72.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.72.1.tgz", + "integrity": "sha512-NTc5UGy/NWFGpSqF1lFY8z9Adri6uhyMLI6LvPAXdBKoPRFhIIiBUpt+Qg2awixqO3xvzSijjhnb4+QEZwJmxA==", "dev": true, "requires": { "fsevents": "~2.3.2" diff --git a/package.json b/package.json index be9c02b..82f1ae2 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "prettier": "^2.6.1", "pug": "^3.0.2", "pug-loader": "^2.4.0", - "rollup": "2.70.2", + "rollup": "2.72.1", "rollup-plugin-copy": "3.4.0", "rollup-plugin-terser": "^7.0.2", "style-loader": "^3.3.1", From 3fdd613d8a3a42661dadd6dbbc4ca885fb06bd4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 04:18:58 +0000 Subject: [PATCH 29/32] Bump ts-loader from 9.2.8 to 9.3.0 Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.2.8 to 9.3.0. - [Release notes](https://github.com/TypeStrong/ts-loader/releases) - [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md) - [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.2.8...v9.3.0) --- updated-dependencies: - dependency-name: ts-loader dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc8a4e..d2ba99c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11897,9 +11897,10 @@ } }, "node_modules/ts-loader": { - "version": "9.2.8", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.0.tgz", + "integrity": "sha512-2kLLAdAD+FCKijvGKi9sS0OzoqxLCF3CxHpok7rVgCZ5UldRzH0TkbwG9XECKjBzHsAewntC5oDaI/FwKzEUog==", "dev": true, - "license": "MIT", "dependencies": { "chalk": "^4.1.0", "enhanced-resolve": "^5.0.0", @@ -20973,7 +20974,9 @@ } }, "ts-loader": { - "version": "9.2.8", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.0.tgz", + "integrity": "sha512-2kLLAdAD+FCKijvGKi9sS0OzoqxLCF3CxHpok7rVgCZ5UldRzH0TkbwG9XECKjBzHsAewntC5oDaI/FwKzEUog==", "dev": true, "requires": { "chalk": "^4.1.0", From e22ed407a8145b4995a4f9e1b646f0af43424195 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Mon, 9 May 2022 19:23:37 -0500 Subject: [PATCH 30/32] Fix Jest unit test coverage reporting --- jest.config.ts | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index f62cbf4..b5445a9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -42,7 +42,10 @@ const config: Config.InitialOptions = { * coverage information will be collected for it even if no tests exist for this file and * it's never required in the test suite. */ - collectCoverageFrom: ['test/*.spec.ts'], + collectCoverageFrom: [ + 'src/**/*.ts', + '!src/index.ts|src/constants.ts|src/helpers.ts', + ], /** * A list of reporter names that Jest uses when writing coverage reports. diff --git a/package.json b/package.json index 82f1ae2..951c6cf 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "docs": "webpack --mode=production", "start": "webpack serve --mode=development", "test:watch": "jest --watch", - "coverage": "jest --coverage", + "coverage": "jest --coverage && open coverage/lcov-report/index.html -a 'Google Chrome'", "test": "jest --run-in-band", "prepack": "clean-package", "postpack": "clean-package restore", From 4e64a8796ffa5101393d8f035f09f3e1c08fe5a5 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Mon, 9 May 2022 19:34:44 -0500 Subject: [PATCH 31/32] 4.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3ea6235..4c494b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pushin", - "version": "4.0.3", + "version": "4.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pushin", - "version": "4.0.3", + "version": "4.1.0", "hasInstallScript": true, "license": "MIT", "devDependencies": { diff --git a/package.json b/package.json index 951c6cf..7b68ed6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pushin", "description": "A javascript plugin to attach a 'dolly' or 'push-in' effect to a div element when user scrolls.", - "version": "4.0.3", + "version": "4.1.0", "sideEffects": true, "module": "dist/esm/pushin.js", "main": "dist/umd/pushin.js", From 31e76893c4d060f3aad9d714cf9da1a219010942 Mon Sep 17 00:00:00 2001 From: Nathan Blair Date: Mon, 9 May 2022 19:35:26 -0500 Subject: [PATCH 32/32] build v4.1.0 --- dist/esm/constants.d.ts | 1 + dist/esm/pushInLayer.d.ts | 68 ++++++ dist/esm/pushInScene.d.ts | 27 +++ dist/esm/pushin.d.ts | 11 +- dist/esm/pushin.js | 494 ++++++++++++++++++++------------------ dist/esm/pushin.js.map | 2 +- dist/esm/types.d.ts | 24 +- dist/umd/pushin.js | 494 ++++++++++++++++++++------------------ dist/umd/pushin.js.map | 2 +- dist/umd/pushin.min.js | 2 +- 10 files changed, 634 insertions(+), 491 deletions(-) create mode 100644 dist/esm/pushInLayer.d.ts create mode 100644 dist/esm/pushInScene.d.ts diff --git a/dist/esm/constants.d.ts b/dist/esm/constants.d.ts index 9a6e8e5..0b992ee 100644 --- a/dist/esm/constants.d.ts +++ b/dist/esm/constants.d.ts @@ -3,3 +3,4 @@ export declare const PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE = "pushinBreakpoints"; export declare const PUSH_IN_SPEED_DATA_ATTRIBUTE = "pushinSpeed"; export declare const PUSH_IN_TO_DATA_ATTRIBUTE = "pushinTo"; export declare const PUSH_IN_FROM_DATA_ATTRIBUTE = "pushinFrom"; +export declare const PUSH_IN_DEFAULT_BREAKPOINTS: number[]; diff --git a/dist/esm/pushInLayer.d.ts b/dist/esm/pushInLayer.d.ts new file mode 100644 index 0000000..1bc6104 --- /dev/null +++ b/dist/esm/pushInLayer.d.ts @@ -0,0 +1,68 @@ +import { PushInScene } from './pushInScene'; +import { LayerOptions } from './types'; +export declare class PushInLayer { + private element; + private index; + private scene; + private options; + private originalScale; + private ref; + private params; + constructor(element: HTMLElement, index: number, scene: PushInScene, options: LayerOptions | null); + /** + * Get all inpoints for the layer. + */ + private getInpoints; + /** + * Get all outpoints for the layer. + */ + private getOutpoints; + /** + * Get the push-in speed for the layer. + */ + private getSpeed; + /** + * Set the z-index of each layer so they overlap correctly. + */ + setZIndex(total: number): void; + /** + * Reset all the layer parameters. + * + * This is used if the window is resized + * and things need to be recalculated. + */ + resetLayerParams(): void; + /** + * Get the initial scale of the element at time of DOM load. + */ + private getElementScaleX; + /** + * Whether or not a layer should currently be zooming. + */ + private isActive; + /** + * Get the current inpoint for a layer, + * depending on window breakpoint. + */ + private getInpoint; + /** + * Get the current outpoint for a layer, + * depending on window breakpoint. + */ + private getOutpoint; + /** + * Get the scaleX value for the layer. + */ + private getScaleValue; + /** + * Set element scale. + */ + private setScale; + /** + * Set CSS styles to control the effect on each layer. + * + * This will control the scale and opacity of the layer + * as the user scrolls. + */ + setLayerStyle(): void; +} diff --git a/dist/esm/pushInScene.d.ts b/dist/esm/pushInScene.d.ts new file mode 100644 index 0000000..018b850 --- /dev/null +++ b/dist/esm/pushInScene.d.ts @@ -0,0 +1,27 @@ +import { PushInLayer } from './pushInLayer'; +import { PushIn } from './pushin'; +import { SceneOptions } from './types'; +export declare class PushInScene { + pushin: PushIn; + private container; + layers: PushInLayer[]; + speedDelta: number; + transitionLength: number; + layerDepth: number; + options: SceneOptions; + constructor(pushin: PushIn); + /** + * Set breakpoints for responsive design settings. + */ + private setBreakpoints; + /** + * Find all layers on the page and store them with their parameters + */ + private getLayers; + /** + * Get the array index of the current window breakpoint. + */ + getBreakpointIndex(breakpoints: number[]): number; + getTop(): number; + getInpoints(): number[]; +} diff --git a/dist/esm/pushin.d.ts b/dist/esm/pushin.d.ts index 4beec98..9ffea91 100644 --- a/dist/esm/pushin.d.ts +++ b/dist/esm/pushin.d.ts @@ -1,4 +1,4 @@ -import { PushInOptions } from './types'; +import { PushInOptions, SceneOptions } from './types'; /** * PushIn object * @@ -6,16 +6,15 @@ import { PushInOptions } from './types'; * bind events to begin interacting with dom. */ export declare class PushIn { - private container; + container: HTMLElement; private scene; private pushinDebug?; - private layerOptions; - public sceneOptions; - public scrollY; + sceneOptions: SceneOptions; + scrollY: number; private readonly layers; private readonly debug; private lastAnimationFrameId; - public cleanupFns; + cleanupFns: VoidFunction[]; constructor(container: HTMLElement, options?: PushInOptions); /** * Initialize the object to start everything up. diff --git a/dist/esm/pushin.js b/dist/esm/pushin.js index c4e5d63..a966638 100644 --- a/dist/esm/pushin.js +++ b/dist/esm/pushin.js @@ -1,4 +1,4 @@ -/* Pushin.js - v4.0.3 +/* Pushin.js - v4.1.0 Author: Nathan Blair (https://natehub.net) License: MIT */ const DEFAULT_SPEED = 8; @@ -10,176 +10,66 @@ const PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE = 'pushinBreakpoints'; const PUSH_IN_SPEED_DATA_ATTRIBUTE = 'pushinSpeed'; const PUSH_IN_TO_DATA_ATTRIBUTE = 'pushinTo'; const PUSH_IN_FROM_DATA_ATTRIBUTE = 'pushinFrom'; +const PUSH_IN_DEFAULT_BREAKPOINTS = [768, 1440, 1920]; -/** - * PushIn object - * - * Once new object is created, it will initialize itself and - * bind events to begin interacting with dom. - */ -class PushIn { - constructor(container, options) { - var _a, _b, _c; - this.container = container; - this.scrollY = 0; - this.scrollEnd = null; - this.touchStart = null; - this.pageHeight = null; - this.layers = []; - this.speedDelta = 100; - this.transitionLength = 200; - this.layerDepth = 1000; - this.lastAnimationFrameId = -1; - this.cleanupFns = []; - this.debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false; - this.layerOptions = (_b = options === null || options === void 0 ? void 0 : options.layers) !== null && _b !== void 0 ? _b : []; - this.sceneOptions = (_c = options === null || options === void 0 ? void 0 : options.scene) !== null && _c !== void 0 ? _c : { breakpoints: [], inpoints: [] }; - } - /** - * Initialize the object to start everything up. - */ - start() { - if (this.container) { - this.scrollY = this.getScrollY(); - if (this.debug) { - this.showDebugger(); - } - this.addScene(); - this.setBreakpoints(); - this.getLayers(); - this.setScrollLength(); - if (typeof window !== 'undefined') { - this.bindEvents(); - } - // Set layer initial state - this.toggleLayers(); - } - else { - // eslint-disable-next-line no-console - console.error('No container element provided to pushIn.js. Effect will not be applied.'); - } - } - /** - * Does all necessary cleanups by removing event listeners. - */ - destroy() { - cancelAnimationFrame(this.lastAnimationFrameId); - while (this.cleanupFns.length) { - this.cleanupFns.pop()(); - } - } - /** - * If there is a window object, - * get the current scroll position. - * - * Otherwise default to 0. - */ - getScrollY() { - return typeof window !== 'undefined' ? window.scrollY : 0; - } - /** - * Get the "scene" element from the DOM. - * If it doesn't exist, make one. - */ - addScene() { - const scene = this.container.querySelector('.pushin-scene'); - if (scene) { - this.scene = scene; - } - else { - this.scene = document.createElement('div'); - this.scene.classList.add('pushin-scene'); - this.scene.innerHTML = this.container.innerHTML; - this.container.innerHTML = ''; - this.container.appendChild(this.scene); - // We register the cleanup function only for the manually created scene. - this.cleanupFns.push(() => this.container.removeChild(this.scene)); - } - } - /** - * Set breakpoints for responsive design settings. - */ - setBreakpoints() { - if (this.sceneOptions.breakpoints.length === 0) { - this.sceneOptions.breakpoints = [768, 1440, 1920]; - } - if (this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { - this.sceneOptions.breakpoints = this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE].split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); - } - // Always include break point 0 for anything under first breakpoint - this.sceneOptions.breakpoints.unshift(0); - } - /** - * Find all layers on the page and store them with their parameters - */ - getLayers() { - const layers = Array.from(this.container.getElementsByClassName('pushin-layer')); - for (let index = 0; index < layers.length; index++) { - const element = layers[index]; - const inpoints = this.getInpoints(element, index); - const outpoints = this.getOutpoints(element, inpoints[0], index); - const speed = this.getSpeed(element, index); - const layer = { - element, - index, - originalScale: this.getElementScaleX(element), - ref: { inpoints, outpoints, speed }, - params: { - inpoint: this.getInpoint(inpoints), - outpoint: this.getOutpoint(outpoints), - speed, - }, - }; - this.layers.push(layer); - this.setZIndex(layer, layers.length); - } +class PushInLayer { + constructor(element, index, scene, options) { + this.element = element; + this.index = index; + this.scene = scene; + this.options = options; + const inpoints = this.getInpoints(this.element, this.index); + const outpoints = this.getOutpoints(this.element, inpoints[0]); + const speed = this.getSpeed(this.element); + this.originalScale = this.getElementScaleX(element); + this.ref = { inpoints, outpoints, speed }; + this.params = { + inpoint: this.getInpoint(inpoints), + outpoint: this.getOutpoint(outpoints), + speed, + }; } /** * Get all inpoints for the layer. */ getInpoints(element, index) { - var _a, _b; - const { top } = this.scene.getBoundingClientRect(); - let inpoints = [top]; + var _a; + let inpoints = [this.scene.getTop()]; if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE].split(',').map(inpoint => parseInt(inpoint.trim(), 10)); } - else if ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.inpoints) { - inpoints = this.layerOptions[index].inpoints; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.inpoints) { + inpoints = this.options.inpoints; } - else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - // Custom inpoint - inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE].split(',').map(inpoint => parseInt(inpoint.trim(), 10)); - } - else if (index === 0 && ((_b = this.sceneOptions) === null || _b === void 0 ? void 0 : _b.inpoints.length) > 0) { - inpoints = this.sceneOptions.inpoints; + else if (index === 0) { + inpoints = this.scene.getInpoints(); } else if (index > 0) { // Set default for middle layers if none provided - const { outpoint } = this.layers[index - 1].params; - inpoints = [outpoint - this.speedDelta]; + const { outpoint } = this.scene.layers[index - 1].params; + inpoints = [outpoint - this.scene.speedDelta]; } return inpoints; } /** * Get all outpoints for the layer. */ - getOutpoints(element, inpoint, index) { + getOutpoints(element, inpoint) { var _a; - let outpoints = [inpoint + this.layerDepth]; + let outpoints = [inpoint + this.scene.layerDepth]; if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE].split(','); outpoints = values.map(value => parseInt(value.trim(), 10)); } - else if ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.outpoints) { - outpoints = this.layerOptions[index].outpoints; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.outpoints) { + outpoints = this.options.outpoints; } return outpoints; } /** * Get the push-in speed for the layer. */ - getSpeed(element, index) { + getSpeed(element) { var _a; let speed = null; if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { @@ -188,60 +78,16 @@ class PushIn { speed = DEFAULT_SPEED; } } - else if (typeof index === 'number' && ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.speed)) { - speed = this.layerOptions[index].speed; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.speed) { + speed = this.options.speed; } return speed || DEFAULT_SPEED; } - /** - * Get the array index of the current window breakpoint. - */ - getBreakpointIndex() { - const windowWidth = typeof window !== 'undefined' ? window.innerWidth : 0; - const searchIndex = this.sceneOptions.breakpoints - .reverse() - .findIndex(bp => bp <= windowWidth); - return searchIndex === -1 - ? 0 - : this.sceneOptions.breakpoints.length - 1 - searchIndex; - } /** * Set the z-index of each layer so they overlap correctly. */ - setZIndex(layer, total) { - layer.element.style.zIndex = (total - layer.index).toString(); - } - /** - * Bind event listeners to watch for page load and user interaction. - */ - bindEvents() { - const onScroll = () => { - this.scrollY = this.getScrollY(); - this.dolly(); - }; - window.addEventListener('scroll', onScroll); - this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); - let resizeTimeout; - const onResize = () => { - clearTimeout(resizeTimeout); - resizeTimeout = window.setTimeout(() => { - this.resetLayerParams(); - this.setScrollLength(); - this.toggleLayers(); - }, 300); - }; - window.addEventListener('resize', onResize); - this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); - if (this.pushinDebug) { - window.addEventListener('scroll', () => { - var _a; - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; - const content = (_a = this.pushinDebug) === null || _a === void 0 ? void 0 : _a.querySelector('.pushin-debug__content'); - if (content) { - content.textContent = `Scroll position: ${Math.round(scrollY)}px`; - } - }); - } + setZIndex(total) { + this.element.style.zIndex = (total - this.index).toString(); } /** * Reset all the layer parameters. @@ -250,13 +96,11 @@ class PushIn { * and things need to be recalculated. */ resetLayerParams() { - this.layers.forEach(layer => { - layer.params = { - inpoint: this.getInpoint(layer.ref.inpoints), - outpoint: this.getOutpoint(layer.ref.outpoints), - speed: layer.ref.speed, - }; - }); + this.params = { + inpoint: this.getInpoint(this.ref.inpoints), + outpoint: this.getOutpoint(this.ref.outpoints), + speed: this.ref.speed, + }; } /** * Get the initial scale of the element at time of DOM load. @@ -275,48 +119,36 @@ class PushIn { } return scaleX; } - /** - * Animation effect, mimicking a camera dolly on the webpage. - */ - dolly() { - cancelAnimationFrame(this.lastAnimationFrameId); - this.lastAnimationFrameId = requestAnimationFrame(() => { - this.toggleLayers(); - }); - } - /** - * Show or hide layers and set their scale, depending on if active. - */ - toggleLayers() { - this.layers.forEach(layer => this.setLayerStyle(layer)); - } /** * Whether or not a layer should currently be zooming. */ - isActive(layer) { - const { inpoint } = layer.params; - const { outpoint } = layer.params; - return this.scrollY >= inpoint && this.scrollY <= outpoint; + isActive() { + const { inpoint } = this.params; + const { outpoint } = this.params; + return (this.scene.pushin.scrollY >= inpoint && + this.scene.pushin.scrollY <= outpoint); } /** * Get the current inpoint for a layer, * depending on window breakpoint. */ getInpoint(inpoints) { - return inpoints[this.getBreakpointIndex()] || inpoints[0]; + const { breakpoints } = this.scene.options; + return inpoints[this.scene.getBreakpointIndex(breakpoints)] || inpoints[0]; } /** * Get the current outpoint for a layer, * depending on window breakpoint. */ getOutpoint(outpoints) { - return outpoints[this.getBreakpointIndex()] || outpoints[0]; + const { breakpoints } = this.scene.options; + return (outpoints[this.scene.getBreakpointIndex(breakpoints)] || outpoints[0]); } /** * Get the scaleX value for the layer. */ getScaleValue(layer) { - const distance = this.scrollY - layer.params.inpoint; + const distance = this.scene.pushin.scrollY - layer.params.inpoint; const speed = Math.min(layer.params.speed, 100) / 100; const delta = (distance * speed) / 100; return Math.max(layer.originalScale + delta, 0); @@ -338,35 +170,225 @@ class PushIn { * This will control the scale and opacity of the layer * as the user scrolls. */ - setLayerStyle(layer) { + setLayerStyle() { let opacity = 0; - const isFirst = layer.index === 0; - const isLast = layer.index + 1 === this.layers.length; - const { inpoint } = layer.params; - const { outpoint } = layer.params; - if (isFirst && this.scrollY < inpoint) { + const isFirst = this.index === 0; + const isLast = this.index + 1 === this.scene.layers.length; + const { inpoint } = this.params; + const { outpoint } = this.params; + if (isFirst && this.scene.pushin.scrollY < inpoint) { opacity = 1; } - else if (isLast && this.scrollY > outpoint) { + else if (isLast && this.scene.pushin.scrollY > outpoint) { opacity = 1; } - else if (this.isActive(layer)) { - this.setScale(layer.element, this.getScaleValue(layer)); - let inpointDistance = Math.max(Math.min(this.scrollY - inpoint, this.transitionLength), 0) / - this.transitionLength; + else if (this.isActive()) { + this.setScale(this.element, this.getScaleValue(this)); + let inpointDistance = Math.max(Math.min(this.scene.pushin.scrollY - inpoint, this.scene.transitionLength), 0) / this.scene.transitionLength; // Set opacity to 1 if its the first layer and it is active (no fading in here) if (isFirst) { inpointDistance = 1; } - let outpointDistance = Math.max(Math.min(outpoint - this.scrollY, this.transitionLength), 0) / - this.transitionLength; + let outpointDistance = Math.max(Math.min(outpoint - this.scene.pushin.scrollY, this.scene.transitionLength), 0) / this.scene.transitionLength; // Set opacity to 1 if its the last layer and it is active (no fading out) if (isLast) { outpointDistance = 1; } opacity = Math.min(inpointDistance, outpointDistance); } - layer.element.style.opacity = opacity.toString(); + this.element.style.opacity = opacity.toString(); + } +} + +class PushInScene { + constructor(pushin) { + var _a, _b, _c; + this.pushin = pushin; + const container = this.pushin.container.querySelector('.pushin-scene'); + if (container) { + this.container = container; + } + else { + this.container = document.createElement('div'); + this.container.classList.add('pushin-scene'); + this.container.innerHTML = this.pushin.container.innerHTML; + this.pushin.container.innerHTML = ''; + this.pushin.container.appendChild(this.container); + this.pushin.cleanupFns.push(() => { + this.pushin.container.innerHTML = this.container.innerHTML; + }); + } + this.options = pushin.sceneOptions; + this.speedDelta = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.speedDelta) || 100; + this.layerDepth = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.layerDepth) || 1000; + this.transitionLength = ((_c = this.options) === null || _c === void 0 ? void 0 : _c.transitionLength) || 200; + this.layers = []; + this.setBreakpoints(); + this.getLayers(); + } + /** + * Set breakpoints for responsive design settings. + */ + setBreakpoints() { + var _a; + if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.breakpoints.length) === 0) { + this.options.breakpoints = [...PUSH_IN_DEFAULT_BREAKPOINTS]; + } + if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { + this.options.breakpoints = this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE].split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); + } + // Always include break point 0 for anything under first breakpoint + this.options.breakpoints.unshift(0); + } + /** + * Find all layers on the page and store them with their parameters + */ + getLayers() { + var _a; + const layers = Array.from(this.container.getElementsByClassName('pushin-layer')); + for (let index = 0; index < layers.length; index++) { + const element = layers[index]; + let options = {}; + if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.layers) && this.options.layers.length > index) { + options = this.options.layers[index]; + } + const layer = new PushInLayer(element, index, this, options); + this.layers.push(layer); + layer.setZIndex(layers.length); + } + } + /** + * Get the array index of the current window breakpoint. + */ + getBreakpointIndex(breakpoints) { + const searchIndex = breakpoints + .reverse() + .findIndex(bp => bp <= window.innerWidth); + return searchIndex === -1 ? 0 : breakpoints.length - 1 - searchIndex; + } + getTop() { + return this.container.getBoundingClientRect().top; + } + getInpoints() { + var _a, _b; + let inpoints = [this.getTop()]; + if (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + const pushInFrom = (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]); + inpoints.push(parseInt(pushInFrom, 10)); + } + else if (((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.inpoints) === null || _b === void 0 ? void 0 : _b.length) > 0) { + inpoints = this.options.inpoints; + } + return inpoints; + } +} + +/** + * PushIn object + * + * Once new object is created, it will initialize itself and + * bind events to begin interacting with dom. + */ +class PushIn { + constructor(container, options) { + var _a; + this.container = container; + this.scrollY = 0; + this.layers = []; + this.lastAnimationFrameId = -1; + this.cleanupFns = []; + this.debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false; + this.sceneOptions = { breakpoints: [], inpoints: [] }; + if (options === null || options === void 0 ? void 0 : options.scene) { + Object.assign(this.sceneOptions, options.scene); + } + if (options === null || options === void 0 ? void 0 : options.layers) { + Object.assign(this.sceneOptions, options.layers); + } + } + /** + * Initialize the object to start everything up. + */ + start() { + this.scrollY = this.getScrollY(); + if (this.debug) { + this.showDebugger(); + } + if (this.container) { + this.scene = new PushInScene(this); + this.setScrollLength(); + if (typeof window !== 'undefined') { + this.bindEvents(); + } + // Set layer initial state + this.toggleLayers(); + } + else { + // eslint-disable-next-line no-console + console.error('No container element provided to pushIn.js. Effect will not be applied.'); + } + } + /** + * Does all necessary cleanups by removing event listeners. + */ + destroy() { + cancelAnimationFrame(this.lastAnimationFrameId); + while (this.cleanupFns.length) { + this.cleanupFns.pop()(); + } + } + /** + * If there is a window object, + * get the current scroll position. + * + * Otherwise default to 0. + */ + getScrollY() { + return typeof window !== 'undefined' ? window.scrollY : 0; + } + /** + * Bind event listeners to watch for page load and user interaction. + */ + bindEvents() { + const onScroll = () => { + var _a; + this.scrollY = this.getScrollY(); + this.dolly(); + if (this.pushinDebug) { + const content = (_a = this.pushinDebug) === null || _a === void 0 ? void 0 : _a.querySelector('.pushin-debug__content'); + if (content) { + content.textContent = `Scroll position: ${Math.round(this.scrollY)}px`; + } + } + }; + window.addEventListener('scroll', onScroll); + this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); + let resizeTimeout; + const onResize = () => { + clearTimeout(resizeTimeout); + resizeTimeout = window.setTimeout(() => { + this.scene.layers.forEach(layer => layer.resetLayerParams()); + this.setScrollLength(); + this.toggleLayers(); + }, 300); + }; + window.addEventListener('resize', onResize); + this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); + } + /** + * Animation effect, mimicking a camera dolly on the webpage. + */ + dolly() { + cancelAnimationFrame(this.lastAnimationFrameId); + this.lastAnimationFrameId = requestAnimationFrame(() => { + this.toggleLayers(); + }); + } + /** + * Show or hide layers and set their scale, depending on if active. + */ + toggleLayers() { + this.scene.layers.forEach(layer => layer.setLayerStyle()); } /** * Set the default container height based on a few factors: @@ -379,8 +401,9 @@ class PushIn { */ setScrollLength() { const containerHeight = getComputedStyle(this.container).height.replace('px', ''); - const transitions = (this.layers.length - 1) * this.speedDelta; - const scrollLength = this.layers.length * (this.layerDepth + this.transitionLength); + const transitions = (this.scene.layers.length - 1) * this.scene.speedDelta; + const scrollLength = this.scene.layers.length * + (this.scene.layerDepth + this.scene.transitionLength); this.container.style.height = `${Math.max(parseFloat(containerHeight), scrollLength - transitions)}px`; } /** @@ -393,10 +416,9 @@ class PushIn { const scrollTitle = document.createElement('p'); scrollTitle.innerText = 'Pushin.js Debugger'; scrollTitle.classList.add('pushin-debug__title'); - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; const debuggerContent = document.createElement('div'); debuggerContent.classList.add('pushin-debug__content'); - debuggerContent.innerText = `Scroll position: ${scrollY}px`; + debuggerContent.innerText = `Scroll position: ${this.scrollY}px`; this.pushinDebug.appendChild(scrollTitle); this.pushinDebug.appendChild(debuggerContent); document.body.appendChild(this.pushinDebug); diff --git a/dist/esm/pushin.js.map b/dist/esm/pushin.js.map index 0ed146d..1a11619 100644 --- a/dist/esm/pushin.js.map +++ b/dist/esm/pushin.js.map @@ -1 +1 @@ -{"version":3,"file":"pushin.js","sources":["../../src/constants.ts","../../src/pushin.ts","../../src/helpers.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B;AACA;AACO,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;AAEtE;AACA;AACO,MAAM,4BAA4B,GAAG,aAAa,CAAC;AAEnD,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAC7C,MAAM,2BAA2B,GAAG,YAAY;;ACGvD;;;;;AAKG;MACU,MAAM,CAAA;IAqBjB,WAAoB,CAAA,SAAsB,EAAE,OAAuB,EAAA;;QAA/C,IAAS,CAAA,SAAA,GAAT,SAAS,CAAa;QAflC,IAAO,CAAA,OAAA,GAAG,CAAC,CAAC;QACZ,IAAS,CAAA,SAAA,GAAkB,IAAI,CAAC;QAChC,IAAU,CAAA,UAAA,GAAkB,IAAI,CAAC;QACjC,IAAU,CAAA,UAAA,GAAkB,IAAI,CAAC;QAExB,IAAM,CAAA,MAAA,GAAkB,EAAE,CA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AC,eAAe,CAAC,CAAC;QAE9C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC7C;AACF;;AC7dD;;;AAGG;AACH,MAAM,WAAW,GAAG,CAAC,OAAuB,KAAc;IACxD,MAAM,aAAa,GAAG,OAAO,KAAA,IAAA,IAAP,OAAO,KAAP,KAAA,CAAA,GAAA,OAAO,GAAI,EAAE,CAAC;IAEpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAc,SAAS,CAAC,CAAC;IACnE,MAAM,SAAS,GAAa,EAAE,CAAC;AAC/B,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACpD,QAAQ,CAAC,KAAK,EAAE,CAAC;AAEjB,QAAA,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,KAAA;AAED,IAAA,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,IAAA,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC;;;;"} \ No newline at end of file +{"version":3,"file":"pushin.js","sources":["../../src/constants.ts","../../src/pushInLayer.ts","../../src/pushInScene.ts","../../src/pushin.ts","../../src/helpers.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B;AACA;AACO,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;AAEtE;AACA;AACO,MAAM,4BAA4B,GAAG,aAAa,CAAC;AAEnD,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAC7C,MAAM,2BAA2B,GAAG,YAAY,CAAC;AAEjD,MAAM,2BAA2B,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;;MCH/C,WAAW,CAAA;AAKtB,IAAA,WAAA,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AAS,CAAC;AACnB,CAAC,CAAC;AAEF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,IAAA,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC;;;;"} \ No newline at end of file diff --git a/dist/esm/types.d.ts b/dist/esm/types.d.ts index e80f6a6..0613897 100644 --- a/dist/esm/types.d.ts +++ b/dist/esm/types.d.ts @@ -4,8 +4,12 @@ export interface LayerOptions { speed: number; } export interface SceneOptions { + speedDelta?: number; + layerDepth?: number; + transitionLength?: number; breakpoints: number[]; inpoints: number[]; + layers?: LayerOptions[]; } export interface PushInOptions { debug?: boolean; @@ -16,14 +20,14 @@ export interface PushInLayer { element: HTMLElement; index: number; originalScale: number; - ref: { - inpoints: number[]; - outpoints: number[]; - speed: number; - }; - params: { - inpoint: number; - outpoint: number; - speed: number; - }; +} +export interface LayerRef { + inpoints: number[]; + outpoints: number[]; + speed: number; +} +export interface LayerParams { + inpoint: number; + outpoint: number; + speed: number; } diff --git a/dist/umd/pushin.js b/dist/umd/pushin.js index d880b82..0612263 100644 --- a/dist/umd/pushin.js +++ b/dist/umd/pushin.js @@ -1,4 +1,4 @@ -/* Pushin.js - v4.0.3 +/* Pushin.js - v4.1.0 Author: Nathan Blair (https://natehub.net) License: MIT */ (function (global, factory) { @@ -16,176 +16,66 @@ License: MIT */ const PUSH_IN_SPEED_DATA_ATTRIBUTE = 'pushinSpeed'; const PUSH_IN_TO_DATA_ATTRIBUTE = 'pushinTo'; const PUSH_IN_FROM_DATA_ATTRIBUTE = 'pushinFrom'; + const PUSH_IN_DEFAULT_BREAKPOINTS = [768, 1440, 1920]; - /** - * PushIn object - * - * Once new object is created, it will initialize itself and - * bind events to begin interacting with dom. - */ - class PushIn { - constructor(container, options) { - var _a, _b, _c; - this.container = container; - this.scrollY = 0; - this.scrollEnd = null; - this.touchStart = null; - this.pageHeight = null; - this.layers = []; - this.speedDelta = 100; - this.transitionLength = 200; - this.layerDepth = 1000; - this.lastAnimationFrameId = -1; - this.cleanupFns = []; - this.debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false; - this.layerOptions = (_b = options === null || options === void 0 ? void 0 : options.layers) !== null && _b !== void 0 ? _b : []; - this.sceneOptions = (_c = options === null || options === void 0 ? void 0 : options.scene) !== null && _c !== void 0 ? _c : { breakpoints: [], inpoints: [] }; - } - /** - * Initialize the object to start everything up. - */ - start() { - if (this.container) { - this.scrollY = this.getScrollY(); - if (this.debug) { - this.showDebugger(); - } - this.addScene(); - this.setBreakpoints(); - this.getLayers(); - this.setScrollLength(); - if (typeof window !== 'undefined') { - this.bindEvents(); - } - // Set layer initial state - this.toggleLayers(); - } - else { - // eslint-disable-next-line no-console - console.error('No container element provided to pushIn.js. Effect will not be applied.'); - } - } - /** - * Does all necessary cleanups by removing event listeners. - */ - destroy() { - cancelAnimationFrame(this.lastAnimationFrameId); - while (this.cleanupFns.length) { - this.cleanupFns.pop()(); - } - } - /** - * If there is a window object, - * get the current scroll position. - * - * Otherwise default to 0. - */ - getScrollY() { - return typeof window !== 'undefined' ? window.scrollY : 0; - } - /** - * Get the "scene" element from the DOM. - * If it doesn't exist, make one. - */ - addScene() { - const scene = this.container.querySelector('.pushin-scene'); - if (scene) { - this.scene = scene; - } - else { - this.scene = document.createElement('div'); - this.scene.classList.add('pushin-scene'); - this.scene.innerHTML = this.container.innerHTML; - this.container.innerHTML = ''; - this.container.appendChild(this.scene); - // We register the cleanup function only for the manually created scene. - this.cleanupFns.push(() => this.container.removeChild(this.scene)); - } - } - /** - * Set breakpoints for responsive design settings. - */ - setBreakpoints() { - if (this.sceneOptions.breakpoints.length === 0) { - this.sceneOptions.breakpoints = [768, 1440, 1920]; - } - if (this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { - this.sceneOptions.breakpoints = this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE].split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); - } - // Always include break point 0 for anything under first breakpoint - this.sceneOptions.breakpoints.unshift(0); - } - /** - * Find all layers on the page and store them with their parameters - */ - getLayers() { - const layers = Array.from(this.container.getElementsByClassName('pushin-layer')); - for (let index = 0; index < layers.length; index++) { - const element = layers[index]; - const inpoints = this.getInpoints(element, index); - const outpoints = this.getOutpoints(element, inpoints[0], index); - const speed = this.getSpeed(element, index); - const layer = { - element, - index, - originalScale: this.getElementScaleX(element), - ref: { inpoints, outpoints, speed }, - params: { - inpoint: this.getInpoint(inpoints), - outpoint: this.getOutpoint(outpoints), - speed, - }, - }; - this.layers.push(layer); - this.setZIndex(layer, layers.length); - } + class PushInLayer { + constructor(element, index, scene, options) { + this.element = element; + this.index = index; + this.scene = scene; + this.options = options; + const inpoints = this.getInpoints(this.element, this.index); + const outpoints = this.getOutpoints(this.element, inpoints[0]); + const speed = this.getSpeed(this.element); + this.originalScale = this.getElementScaleX(element); + this.ref = { inpoints, outpoints, speed }; + this.params = { + inpoint: this.getInpoint(inpoints), + outpoint: this.getOutpoint(outpoints), + speed, + }; } /** * Get all inpoints for the layer. */ getInpoints(element, index) { - var _a, _b; - const { top } = this.scene.getBoundingClientRect(); - let inpoints = [top]; + var _a; + let inpoints = [this.scene.getTop()]; if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE].split(',').map(inpoint => parseInt(inpoint.trim(), 10)); } - else if ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.inpoints) { - inpoints = this.layerOptions[index].inpoints; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.inpoints) { + inpoints = this.options.inpoints; } - else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { - // Custom inpoint - inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE].split(',').map(inpoint => parseInt(inpoint.trim(), 10)); - } - else if (index === 0 && ((_b = this.sceneOptions) === null || _b === void 0 ? void 0 : _b.inpoints.length) > 0) { - inpoints = this.sceneOptions.inpoints; + else if (index === 0) { + inpoints = this.scene.getInpoints(); } else if (index > 0) { // Set default for middle layers if none provided - const { outpoint } = this.layers[index - 1].params; - inpoints = [outpoint - this.speedDelta]; + const { outpoint } = this.scene.layers[index - 1].params; + inpoints = [outpoint - this.scene.speedDelta]; } return inpoints; } /** * Get all outpoints for the layer. */ - getOutpoints(element, inpoint, index) { + getOutpoints(element, inpoint) { var _a; - let outpoints = [inpoint + this.layerDepth]; + let outpoints = [inpoint + this.scene.layerDepth]; if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) { const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE].split(','); outpoints = values.map(value => parseInt(value.trim(), 10)); } - else if ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.outpoints) { - outpoints = this.layerOptions[index].outpoints; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.outpoints) { + outpoints = this.options.outpoints; } return outpoints; } /** * Get the push-in speed for the layer. */ - getSpeed(element, index) { + getSpeed(element) { var _a; let speed = null; if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) { @@ -194,60 +84,16 @@ License: MIT */ speed = DEFAULT_SPEED; } } - else if (typeof index === 'number' && ((_a = this.layerOptions[index]) === null || _a === void 0 ? void 0 : _a.speed)) { - speed = this.layerOptions[index].speed; + else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.speed) { + speed = this.options.speed; } return speed || DEFAULT_SPEED; } - /** - * Get the array index of the current window breakpoint. - */ - getBreakpointIndex() { - const windowWidth = typeof window !== 'undefined' ? window.innerWidth : 0; - const searchIndex = this.sceneOptions.breakpoints - .reverse() - .findIndex(bp => bp <= windowWidth); - return searchIndex === -1 - ? 0 - : this.sceneOptions.breakpoints.length - 1 - searchIndex; - } /** * Set the z-index of each layer so they overlap correctly. */ - setZIndex(layer, total) { - layer.element.style.zIndex = (total - layer.index).toString(); - } - /** - * Bind event listeners to watch for page load and user interaction. - */ - bindEvents() { - const onScroll = () => { - this.scrollY = this.getScrollY(); - this.dolly(); - }; - window.addEventListener('scroll', onScroll); - this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); - let resizeTimeout; - const onResize = () => { - clearTimeout(resizeTimeout); - resizeTimeout = window.setTimeout(() => { - this.resetLayerParams(); - this.setScrollLength(); - this.toggleLayers(); - }, 300); - }; - window.addEventListener('resize', onResize); - this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); - if (this.pushinDebug) { - window.addEventListener('scroll', () => { - var _a; - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; - const content = (_a = this.pushinDebug) === null || _a === void 0 ? void 0 : _a.querySelector('.pushin-debug__content'); - if (content) { - content.textContent = `Scroll position: ${Math.round(scrollY)}px`; - } - }); - } + setZIndex(total) { + this.element.style.zIndex = (total - this.index).toString(); } /** * Reset all the layer parameters. @@ -256,13 +102,11 @@ License: MIT */ * and things need to be recalculated. */ resetLayerParams() { - this.layers.forEach(layer => { - layer.params = { - inpoint: this.getInpoint(layer.ref.inpoints), - outpoint: this.getOutpoint(layer.ref.outpoints), - speed: layer.ref.speed, - }; - }); + this.params = { + inpoint: this.getInpoint(this.ref.inpoints), + outpoint: this.getOutpoint(this.ref.outpoints), + speed: this.ref.speed, + }; } /** * Get the initial scale of the element at time of DOM load. @@ -281,48 +125,36 @@ License: MIT */ } return scaleX; } - /** - * Animation effect, mimicking a camera dolly on the webpage. - */ - dolly() { - cancelAnimationFrame(this.lastAnimationFrameId); - this.lastAnimationFrameId = requestAnimationFrame(() => { - this.toggleLayers(); - }); - } - /** - * Show or hide layers and set their scale, depending on if active. - */ - toggleLayers() { - this.layers.forEach(layer => this.setLayerStyle(layer)); - } /** * Whether or not a layer should currently be zooming. */ - isActive(layer) { - const { inpoint } = layer.params; - const { outpoint } = layer.params; - return this.scrollY >= inpoint && this.scrollY <= outpoint; + isActive() { + const { inpoint } = this.params; + const { outpoint } = this.params; + return (this.scene.pushin.scrollY >= inpoint && + this.scene.pushin.scrollY <= outpoint); } /** * Get the current inpoint for a layer, * depending on window breakpoint. */ getInpoint(inpoints) { - return inpoints[this.getBreakpointIndex()] || inpoints[0]; + const { breakpoints } = this.scene.options; + return inpoints[this.scene.getBreakpointIndex(breakpoints)] || inpoints[0]; } /** * Get the current outpoint for a layer, * depending on window breakpoint. */ getOutpoint(outpoints) { - return outpoints[this.getBreakpointIndex()] || outpoints[0]; + const { breakpoints } = this.scene.options; + return (outpoints[this.scene.getBreakpointIndex(breakpoints)] || outpoints[0]); } /** * Get the scaleX value for the layer. */ getScaleValue(layer) { - const distance = this.scrollY - layer.params.inpoint; + const distance = this.scene.pushin.scrollY - layer.params.inpoint; const speed = Math.min(layer.params.speed, 100) / 100; const delta = (distance * speed) / 100; return Math.max(layer.originalScale + delta, 0); @@ -344,35 +176,225 @@ License: MIT */ * This will control the scale and opacity of the layer * as the user scrolls. */ - setLayerStyle(layer) { + setLayerStyle() { let opacity = 0; - const isFirst = layer.index === 0; - const isLast = layer.index + 1 === this.layers.length; - const { inpoint } = layer.params; - const { outpoint } = layer.params; - if (isFirst && this.scrollY < inpoint) { + const isFirst = this.index === 0; + const isLast = this.index + 1 === this.scene.layers.length; + const { inpoint } = this.params; + const { outpoint } = this.params; + if (isFirst && this.scene.pushin.scrollY < inpoint) { opacity = 1; } - else if (isLast && this.scrollY > outpoint) { + else if (isLast && this.scene.pushin.scrollY > outpoint) { opacity = 1; } - else if (this.isActive(layer)) { - this.setScale(layer.element, this.getScaleValue(layer)); - let inpointDistance = Math.max(Math.min(this.scrollY - inpoint, this.transitionLength), 0) / - this.transitionLength; + else if (this.isActive()) { + this.setScale(this.element, this.getScaleValue(this)); + let inpointDistance = Math.max(Math.min(this.scene.pushin.scrollY - inpoint, this.scene.transitionLength), 0) / this.scene.transitionLength; // Set opacity to 1 if its the first layer and it is active (no fading in here) if (isFirst) { inpointDistance = 1; } - let outpointDistance = Math.max(Math.min(outpoint - this.scrollY, this.transitionLength), 0) / - this.transitionLength; + let outpointDistance = Math.max(Math.min(outpoint - this.scene.pushin.scrollY, this.scene.transitionLength), 0) / this.scene.transitionLength; // Set opacity to 1 if its the last layer and it is active (no fading out) if (isLast) { outpointDistance = 1; } opacity = Math.min(inpointDistance, outpointDistance); } - layer.element.style.opacity = opacity.toString(); + this.element.style.opacity = opacity.toString(); + } + } + + class PushInScene { + constructor(pushin) { + var _a, _b, _c; + this.pushin = pushin; + const container = this.pushin.container.querySelector('.pushin-scene'); + if (container) { + this.container = container; + } + else { + this.container = document.createElement('div'); + this.container.classList.add('pushin-scene'); + this.container.innerHTML = this.pushin.container.innerHTML; + this.pushin.container.innerHTML = ''; + this.pushin.container.appendChild(this.container); + this.pushin.cleanupFns.push(() => { + this.pushin.container.innerHTML = this.container.innerHTML; + }); + } + this.options = pushin.sceneOptions; + this.speedDelta = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.speedDelta) || 100; + this.layerDepth = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.layerDepth) || 1000; + this.transitionLength = ((_c = this.options) === null || _c === void 0 ? void 0 : _c.transitionLength) || 200; + this.layers = []; + this.setBreakpoints(); + this.getLayers(); + } + /** + * Set breakpoints for responsive design settings. + */ + setBreakpoints() { + var _a; + if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.breakpoints.length) === 0) { + this.options.breakpoints = [...PUSH_IN_DEFAULT_BREAKPOINTS]; + } + if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) { + this.options.breakpoints = this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE].split(',').map(breakpoint => parseInt(breakpoint.trim(), 10)); + } + // Always include break point 0 for anything under first breakpoint + this.options.breakpoints.unshift(0); + } + /** + * Find all layers on the page and store them with their parameters + */ + getLayers() { + var _a; + const layers = Array.from(this.container.getElementsByClassName('pushin-layer')); + for (let index = 0; index < layers.length; index++) { + const element = layers[index]; + let options = {}; + if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.layers) && this.options.layers.length > index) { + options = this.options.layers[index]; + } + const layer = new PushInLayer(element, index, this, options); + this.layers.push(layer); + layer.setZIndex(layers.length); + } + } + /** + * Get the array index of the current window breakpoint. + */ + getBreakpointIndex(breakpoints) { + const searchIndex = breakpoints + .reverse() + .findIndex(bp => bp <= window.innerWidth); + return searchIndex === -1 ? 0 : breakpoints.length - 1 - searchIndex; + } + getTop() { + return this.container.getBoundingClientRect().top; + } + getInpoints() { + var _a, _b; + let inpoints = [this.getTop()]; + if (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) { + const pushInFrom = (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]); + inpoints.push(parseInt(pushInFrom, 10)); + } + else if (((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.inpoints) === null || _b === void 0 ? void 0 : _b.length) > 0) { + inpoints = this.options.inpoints; + } + return inpoints; + } + } + + /** + * PushIn object + * + * Once new object is created, it will initialize itself and + * bind events to begin interacting with dom. + */ + class PushIn { + constructor(container, options) { + var _a; + this.container = container; + this.scrollY = 0; + this.layers = []; + this.lastAnimationFrameId = -1; + this.cleanupFns = []; + this.debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false; + this.sceneOptions = { breakpoints: [], inpoints: [] }; + if (options === null || options === void 0 ? void 0 : options.scene) { + Object.assign(this.sceneOptions, options.scene); + } + if (options === null || options === void 0 ? void 0 : options.layers) { + Object.assign(this.sceneOptions, options.layers); + } + } + /** + * Initialize the object to start everything up. + */ + start() { + this.scrollY = this.getScrollY(); + if (this.debug) { + this.showDebugger(); + } + if (this.container) { + this.scene = new PushInScene(this); + this.setScrollLength(); + if (typeof window !== 'undefined') { + this.bindEvents(); + } + // Set layer initial state + this.toggleLayers(); + } + else { + // eslint-disable-next-line no-console + console.error('No container element provided to pushIn.js. Effect will not be applied.'); + } + } + /** + * Does all necessary cleanups by removing event listeners. + */ + destroy() { + cancelAnimationFrame(this.lastAnimationFrameId); + while (this.cleanupFns.length) { + this.cleanupFns.pop()(); + } + } + /** + * If there is a window object, + * get the current scroll position. + * + * Otherwise default to 0. + */ + getScrollY() { + return typeof window !== 'undefined' ? window.scrollY : 0; + } + /** + * Bind event listeners to watch for page load and user interaction. + */ + bindEvents() { + const onScroll = () => { + var _a; + this.scrollY = this.getScrollY(); + this.dolly(); + if (this.pushinDebug) { + const content = (_a = this.pushinDebug) === null || _a === void 0 ? void 0 : _a.querySelector('.pushin-debug__content'); + if (content) { + content.textContent = `Scroll position: ${Math.round(this.scrollY)}px`; + } + } + }; + window.addEventListener('scroll', onScroll); + this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll)); + let resizeTimeout; + const onResize = () => { + clearTimeout(resizeTimeout); + resizeTimeout = window.setTimeout(() => { + this.scene.layers.forEach(layer => layer.resetLayerParams()); + this.setScrollLength(); + this.toggleLayers(); + }, 300); + }; + window.addEventListener('resize', onResize); + this.cleanupFns.push(() => window.removeEventListener('resize', onResize)); + } + /** + * Animation effect, mimicking a camera dolly on the webpage. + */ + dolly() { + cancelAnimationFrame(this.lastAnimationFrameId); + this.lastAnimationFrameId = requestAnimationFrame(() => { + this.toggleLayers(); + }); + } + /** + * Show or hide layers and set their scale, depending on if active. + */ + toggleLayers() { + this.scene.layers.forEach(layer => layer.setLayerStyle()); } /** * Set the default container height based on a few factors: @@ -385,8 +407,9 @@ License: MIT */ */ setScrollLength() { const containerHeight = getComputedStyle(this.container).height.replace('px', ''); - const transitions = (this.layers.length - 1) * this.speedDelta; - const scrollLength = this.layers.length * (this.layerDepth + this.transitionLength); + const transitions = (this.scene.layers.length - 1) * this.scene.speedDelta; + const scrollLength = this.scene.layers.length * + (this.scene.layerDepth + this.scene.transitionLength); this.container.style.height = `${Math.max(parseFloat(containerHeight), scrollLength - transitions)}px`; } /** @@ -399,10 +422,9 @@ License: MIT */ const scrollTitle = document.createElement('p'); scrollTitle.innerText = 'Pushin.js Debugger'; scrollTitle.classList.add('pushin-debug__title'); - const scrollY = typeof window !== 'undefined' ? window.scrollY : 0; const debuggerContent = document.createElement('div'); debuggerContent.classList.add('pushin-debug__content'); - debuggerContent.innerText = `Scroll position: ${scrollY}px`; + debuggerContent.innerText = `Scroll position: ${this.scrollY}px`; this.pushinDebug.appendChild(scrollTitle); this.pushinDebug.appendChild(debuggerContent); document.body.appendChild(this.pushinDebug); diff --git a/dist/umd/pushin.js.map b/dist/umd/pushin.js.map index 509eef2..e7a4689 100644 --- a/dist/umd/pushin.js.map +++ b/dist/umd/pushin.js.map @@ -1 +1 @@ -{"version":3,"file":"pushin.js","sources":["../../src/constants.ts","../../src/pushin.ts","../../src/helpers.ts"],"sourcesContent":["export const DEFAULT_SPEED = 8;\n\n// The data attribute which may be defined on the elemenet in the following way:\n// `
`.\nexport const PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE = 'pushinBreakpoints';\n\n// The data attribute which may be defined on the elemenet in the following way:\n// `
`.\nexport const PUSH_IN_SPEED_DATA_ATTRIBUTE = 'pushinSpeed';\n\nexport const PUSH_IN_TO_DATA_ATTRIBUTE = 'pushinTo';\nexport const PUSH_IN_FROM_DATA_ATTRIBUTE = 'pushinFrom';\n","import {\n DEFAULT_SPEED,\n PUSH_IN_TO_DATA_ATTRIBUTE,\n PUSH_IN_FROM_DATA_ATTRIBUTE,\n PUSH_IN_SPEED_DATA_ATTRIBUTE,\n PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE,\n} from './constants';\nimport {\n PushInLayer,\n PushInOptions,\n LayerOptions,\n SceneOptions,\n} from './types';\n\n/**\n * PushIn object\n *\n * Once new object is created, it will initialize itself and\n * bind events to begin interacting with dom.\n */\nexport class PushIn {\n private scene!: HTMLElement;\n private pushinDebug?: HTMLElement;\n private layerOptions: LayerOptions[];\n private sceneOptions: SceneOptions;\n\n private scrollY = 0;\n private scrollEnd: number | null = null;\n private touchStart: number | null = null;\n private pageHeight: number | null = null;\n\n private readonly layers: PushInLayer[] = [];\n private readonly debug: boolean;\n\n private speedDelta = 100;\n private transitionLength = 200;\n private layerDepth = 1000;\n\n private lastAnimationFrameId = -1;\n private readonly cleanupFns: VoidFunction[] = [];\n\n constructor(private container: HTMLElement, options?: PushInOptions) {\n this.debug = options?.debug ?? false;\n this.layerOptions = options?.layers ?? [];\n this.sceneOptions = options?.scene ?? { breakpoints: [], inpoints: [] };\n }\n\n /**\n * Initialize the object to start everything up.\n */\n start(): void {\n if (this.container) {\n this.scrollY = this.getScrollY();\n\n if (this.debug) {\n this.showDebugger();\n }\n\n this.addScene();\n this.setBreakpoints();\n this.getLayers();\n this.setScrollLength();\n\n if (typeof window !== 'undefined') {\n this.bindEvents();\n }\n\n // Set layer initial state\n this.toggleLayers();\n } else {\n // eslint-disable-next-line no-console\n console.error(\n 'No container element provided to pushIn.js. Effect will not be applied.'\n );\n }\n }\n\n /**\n * Does all necessary cleanups by removing event listeners.\n */\n destroy(): void {\n cancelAnimationFrame(this.lastAnimationFrameId);\n\n while (this.cleanupFns.length) {\n this.cleanupFns.pop()!();\n }\n }\n\n /**\n * If there is a window object,\n * get the current scroll position.\n *\n * Otherwise default to 0.\n */\n private getScrollY(): number {\n return typeof window !== 'undefined' ? window.scrollY : 0;\n }\n\n /**\n * Get the \"scene\" element from the DOM.\n * If it doesn't exist, make one.\n */\n private addScene(): void {\n const scene = this.container.querySelector('.pushin-scene');\n\n if (scene) {\n this.scene = scene;\n } else {\n this.scene = document.createElement('div');\n this.scene.classList.add('pushin-scene');\n\n this.scene.innerHTML = this.container.innerHTML;\n this.container.innerHTML = '';\n this.container.appendChild(this.scene);\n // We register the cleanup function only for the manually created scene.\n this.cleanupFns.push(() => this.container.removeChild(this.scene));\n }\n }\n\n /**\n * Set breakpoints for responsive design settings.\n */\n private setBreakpoints(): void {\n if (this.sceneOptions.breakpoints.length === 0) {\n this.sceneOptions.breakpoints = [768, 1440, 1920];\n }\n\n if (this.scene.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) {\n this.sceneOptions.breakpoints = this.scene.dataset[\n PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE\n ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10));\n }\n\n // Always include break point 0 for anything under first breakpoint\n this.sceneOptions.breakpoints.unshift(0);\n }\n\n /**\n * Find all layers on the page and store them with their parameters\n */\n private getLayers(): void {\n const layers = Array.from(\n this.container.getElementsByClassName('pushin-layer')\n );\n\n for (let index = 0; index < layers.length; index++) {\n const element = layers[index];\n const inpoints = this.getInpoints(element, index);\n const outpoints = this.getOutpoints(element, inpoints[0], index);\n const speed = this.getSpeed(element, index);\n\n const layer: PushInLayer = {\n element,\n index,\n originalScale: this.getElementScaleX(element),\n ref: { inpoints, outpoints, speed },\n params: {\n inpoint: this.getInpoint(inpoints),\n outpoint: this.getOutpoint(outpoints),\n speed,\n },\n };\n\n this.layers.push(layer);\n this.setZIndex(layer, layers.length);\n }\n }\n\n /**\n * Get all inpoints for the layer.\n */\n private getInpoints(element: HTMLElement, index: number): number[] {\n const { top } = this.scene.getBoundingClientRect();\n\n let inpoints = [top];\n if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) {\n inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map(\n inpoint => parseInt(inpoint.trim(), 10)\n );\n } else if (this.layerOptions[index]?.inpoints) {\n inpoints = this.layerOptions[index].inpoints;\n } else if (index === 0 && this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) {\n // Custom inpoint\n inpoints = this.scene.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(\n ','\n ).map(inpoint => parseInt(inpoint.trim(), 10));\n } else if (index === 0 && this.sceneOptions?.inpoints.length > 0) {\n inpoints = this.sceneOptions.inpoints;\n } else if (index > 0) {\n // Set default for middle layers if none provided\n const { outpoint } = this.layers[index - 1].params;\n inpoints = [outpoint - this.speedDelta];\n }\n\n return inpoints;\n }\n\n /**\n * Get all outpoints for the layer.\n */\n private getOutpoints(\n element: HTMLElement,\n inpoint: number,\n index: number\n ): number[] {\n let outpoints = [inpoint + this.layerDepth];\n\n if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) {\n const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(',');\n outpoints = values.map(value => parseInt(value.trim(), 10));\n } else if (this.layerOptions[index]?.outpoints) {\n outpoints = this.layerOptions[index].outpoints;\n }\n\n return outpoints;\n }\n\n /**\n * Get the push-in speed for the layer.\n */\n private getSpeed(element: HTMLElement, index?: number): number {\n let speed: number | null = null;\n\n if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) {\n speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10);\n if (Number.isNaN(speed)) {\n speed = DEFAULT_SPEED;\n }\n } else if (typeof index === 'number' && this.layerOptions[index]?.speed) {\n speed = this.layerOptions[index].speed;\n }\n\n return speed || DEFAULT_SPEED;\n }\n\n /**\n * Get the array index of the current window breakpoint.\n */\n private getBreakpointIndex(): number {\n const windowWidth = typeof window !== 'undefined' ? window.innerWidth : 0;\n const searchIndex = this.sceneOptions.breakpoints\n .reverse()\n .findIndex(bp => bp <= windowWidth);\n return searchIndex === -1\n ? 0\n : this.sceneOptions.breakpoints.length - 1 - searchIndex;\n }\n\n /**\n * Set the z-index of each layer so they overlap correctly.\n */\n private setZIndex(layer: PushInLayer, total: number): void {\n layer.element.style.zIndex = (total - layer.index).toString();\n }\n\n /**\n * Bind event listeners to watch for page load and user interaction.\n */\n bindEvents(): void {\n const onScroll = () => {\n this.scrollY = this.getScrollY();\n this.dolly();\n };\n window.addEventListener('scroll', onScroll);\n this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll));\n\n let resizeTimeout: number;\n const onResize = () => {\n clearTimeout(resizeTimeout);\n\n resizeTimeout = window.setTimeout(() => {\n this.resetLayerParams();\n this.setScrollLength();\n this.toggleLayers();\n }, 300);\n };\n window.addEventListener('resize', onResize);\n this.cleanupFns.push(() => window.removeEventListener('resize', onResize));\n\n if (this.pushinDebug) {\n window.addEventListener('scroll', () => {\n const scrollY = typeof window !== 'undefined' ? window.scrollY : 0;\n const content = this.pushinDebug?.querySelector(\n '.pushin-debug__content'\n );\n if (content) {\n content!.textContent = `Scroll position: ${Math.round(scrollY)}px`;\n }\n });\n }\n }\n\n /**\n * Reset all the layer parameters.\n *\n * This is used if the window is resized\n * and things need to be recalculated.\n */\n private resetLayerParams(): void {\n this.layers.forEach(layer => {\n layer.params = {\n inpoint: this.getInpoint(layer.ref.inpoints),\n outpoint: this.getOutpoint(layer.ref.outpoints),\n speed: layer.ref.speed,\n };\n });\n }\n\n /**\n * Get the initial scale of the element at time of DOM load.\n */\n private getElementScaleX(element: HTMLElement): number {\n const transform = window\n .getComputedStyle(element)\n .getPropertyValue('transform');\n\n let scaleX = 1;\n if (transform && transform !== 'none') {\n const match = transform.match(/[matrix|scale]\\(([\\d,.\\s]+)/);\n if (match && match[1]) {\n const matrix = match[1].split(', ');\n scaleX = parseFloat(matrix[0]);\n }\n }\n\n return scaleX;\n }\n\n /**\n * Animation effect, mimicking a camera dolly on the webpage.\n */\n private dolly(): void {\n cancelAnimationFrame(this.lastAnimationFrameId);\n\n this.lastAnimationFrameId = requestAnimationFrame(() => {\n this.toggleLayers();\n });\n }\n\n /**\n * Show or hide layers and set their scale, depending on if active.\n */\n private toggleLayers(): void {\n this.layers.forEach(layer => this.setLayerStyle(layer));\n }\n\n /**\n * Whether or not a layer should currently be zooming.\n */\n private isActive(layer: PushInLayer): boolean {\n const { inpoint } = layer.params;\n const { outpoint } = layer.params;\n return this.scrollY >= inpoint && this.scrollY <= outpoint;\n }\n\n /**\n * Get the current inpoint for a layer,\n * depending on window breakpoint.\n */\n private getInpoint(inpoints: number[]): number {\n return inpoints[this.getBreakpointIndex()] || inpoints[0];\n }\n\n /**\n * Get the current outpoint for a layer,\n * depending on window breakpoint.\n */\n private getOutpoint(outpoints: number[]): number {\n return outpoints[this.getBreakpointIndex()] || outpoints[0];\n }\n\n /**\n * Get the scaleX value for the layer.\n */\n private getScaleValue(layer: PushInLayer): number {\n const distance = this.scrollY - layer.params.inpoint;\n const speed = Math.min(layer.params.speed, 100) / 100;\n const delta = (distance * speed) / 100;\n\n return Math.max(layer.originalScale + delta, 0);\n }\n\n /**\n * Set element scale.\n */\n private setScale({ style }: HTMLElement, value: number): void {\n const scaleString = `scale(${value})`;\n style.webkitTransform = scaleString;\n (style as unknown as { mozTransform: string }).mozTransform = scaleString;\n (style as unknown as { msTransform: string }).msTransform = scaleString;\n (style as unknown as { oTransform: string }).oTransform = scaleString;\n style.transform = scaleString;\n }\n\n /**\n * Set CSS styles to control the effect on each layer.\n *\n * This will control the scale and opacity of the layer\n * as the user scrolls.\n */\n private setLayerStyle(layer: PushInLayer): void {\n let opacity = 0;\n const isFirst = layer.index === 0;\n const isLast = layer.index + 1 === this.layers.length;\n const { inpoint } = layer.params;\n const { outpoint } = layer.params;\n\n if (isFirst && this.scrollY < inpoint) {\n opacity = 1;\n } else if (isLast && this.scrollY > outpoint) {\n opacity = 1;\n } else if (this.isActive(layer)) {\n this.setScale(layer.element, this.getScaleValue(layer));\n\n let inpointDistance =\n Math.max(Math.min(this.scrollY - inpoint, this.transitionLength), 0) /\n this.transitionLength;\n\n // Set opacity to 1 if its the first layer and it is active (no fading in here)\n if (isFirst) {\n inpointDistance = 1;\n }\n\n let outpointDistance =\n Math.max(Math.min(outpoint - this.scrollY, this.transitionLength), 0) /\n this.transitionLength;\n\n // Set opacity to 1 if its the last layer and it is active (no fading out)\n if (isLast) {\n outpointDistance = 1;\n }\n\n opacity = Math.min(inpointDistance, outpointDistance);\n }\n\n layer.element.style.opacity = opacity.toString();\n }\n\n /**\n * Set the default container height based on a few factors:\n * 1. Number of layers present\n * 2. The transition length between layers\n * 3. The length of scrolling time during each layer\n *\n * If this calculation is smaller than the container's current height,\n * the current height will be used instead.\n */\n private setScrollLength(): void {\n const containerHeight = getComputedStyle(this.container).height.replace(\n 'px',\n ''\n );\n\n const transitions = (this.layers.length - 1) * this.speedDelta;\n const scrollLength =\n this.layers.length * (this.layerDepth + this.transitionLength);\n\n this.container.style.height = `${Math.max(\n parseFloat(containerHeight),\n scrollLength - transitions\n )}px`;\n }\n\n /**\n * Show a debugging tool appended to the frontend of the page.\n * Can be used to determine best \"pushin-from\" and \"pushin-to\" values.\n */\n private showDebugger(): void {\n this.pushinDebug = document.createElement('div');\n this.pushinDebug.classList.add('pushin-debug');\n\n const scrollTitle = document.createElement('p');\n scrollTitle.innerText = 'Pushin.js Debugger';\n scrollTitle.classList.add('pushin-debug__title');\n\n const scrollY = typeof window !== 'undefined' ? window.scrollY : 0;\n\n const debuggerContent = document.createElement('div');\n debuggerContent.classList.add('pushin-debug__content');\n debuggerContent.innerText = `Scroll position: ${scrollY}px`;\n\n this.pushinDebug.appendChild(scrollTitle);\n this.pushinDebug.appendChild(debuggerContent);\n\n document.body.appendChild(this.pushinDebug);\n }\n}\n","import { PushIn } from './pushin';\nimport { PushInOptions } from './types';\n\ndeclare global {\n interface Window {\n pushInStart(options?: PushInOptions | string): void;\n }\n}\n\n/**\n * Helper function: Set up and start push-in effect on all elements\n * matching the provided selector.\n */\nconst pushInStart = (options?: PushInOptions): PushIn[] => {\n const pushInOptions = options ?? {};\n\n const elements = document.querySelectorAll('.pushin');\n const instances: PushIn[] = [];\n for (const element of elements) {\n const instance = new PushIn(element, pushInOptions);\n instance.start();\n\n instances.push(instance);\n }\n\n return instances;\n};\n\nif (typeof window !== 'undefined') {\n window.pushInStart = pushInStart;\n}\n"],"names":[],"mappings":";;;;;;;;;IAAO,MAAM,aAAa,GAAG,CAAC,CAAC;IAE/B;IACA;IACO,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;IAEtE;IACA;IACO,MAAM,4BAA4B,GAAG,aAAa,CAAC;IAEnD,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAC7C,MAAM,2BAA2B,GAAG,YAAY;;ICGvD;;;;;IAKG;UACU,MAAM,CAAA;QAqBjB,WAAo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AC,CAAC;YAEnE,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACtD,QAAA,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvD,QAAA,eAAe,CAAC,SAAS,GAAG,CAAoB,iBAAA,EAAA,OAAO,IAAI,CAAC;IAE5D,QAAA,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC1C,QAAA,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YAE9C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC7C;IACF;;IC7dD;;;IAGG;IACH,MAAM,WAAW,GAAG,CAAC,OAAuB,KAAc;QACxD,MAAM,aAAa,GAAG,OAAO,KAAA,IAAA,IAAP,OAAO,KAAP,KAAA,CAAA,GAAA,OAAO,GAAI,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAc,SAAS,CAAC,CAAC;QACnE,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACpD,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEjB,QAAA,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,KAAA;IAED,IAAA,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,IAAA,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IAClC;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"pushin.js","sources":["../../src/constants.ts","../../src/pushInLayer.ts","../../src/pushInScene.ts","../../src/pushin.ts","../../src/helpers.ts"],"sourcesContent":["export const DEFAULT_SPEED = 8;\n\n// The data attribute which may be defined on the elemenet in the following way:\n// `
`.\nexport const PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE = 'pushinBreakpoints';\n\n// The data attribute which may be defined on the elemenet in the following way:\n// `
`.\nexport const PUSH_IN_SPEED_DATA_ATTRIBUTE = 'pushinSpeed';\n\nexport const PUSH_IN_TO_DATA_ATTRIBUTE = 'pushinTo';\nexport const PUSH_IN_FROM_DATA_ATTRIBUTE = 'pushinFrom';\n\nexport const PUSH_IN_DEFAULT_BREAKPOINTS = [768, 1440, 1920];\n","import {\n DEFAULT_SPEED,\n PUSH_IN_TO_DATA_ATTRIBUTE,\n PUSH_IN_FROM_DATA_ATTRIBUTE,\n PUSH_IN_SPEED_DATA_ATTRIBUTE,\n} from './constants';\nimport { PushInScene } from './pushInScene';\n\nimport { LayerOptions, LayerRef, LayerParams } from './types';\n\nexport class PushInLayer {\n private originalScale: number;\n private ref: LayerRef;\n private params: LayerParams;\n\n constructor(\n private element: HTMLElement,\n private index: number,\n private scene: PushInScene,\n private options: LayerOptions | null\n ) {\n const inpoints = this.getInpoints(this.element, this.index);\n const outpoints = this.getOutpoints(this.element, inpoints[0]);\n const speed = this.getSpeed(this.element);\n\n this.originalScale = this.getElementScaleX(element);\n this.ref = { inpoints, outpoints, speed };\n\n this.params = {\n inpoint: this.getInpoint(inpoints),\n outpoint: this.getOutpoint(outpoints),\n speed,\n };\n }\n\n /**\n * Get all inpoints for the layer.\n */\n private getInpoints(element: HTMLElement, index: number): number[] {\n let inpoints = [this.scene.getTop()];\n if (element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) {\n inpoints = element.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]!.split(',').map(\n inpoint => parseInt(inpoint.trim(), 10)\n );\n } else if (this.options?.inpoints) {\n inpoints = this.options.inpoints;\n } else if (index === 0) {\n inpoints = this.scene.getInpoints();\n } else if (index > 0) {\n // Set default for middle layers if none provided\n const { outpoint } = this.scene.layers[index - 1].params;\n inpoints = [outpoint - this.scene.speedDelta];\n }\n\n return inpoints;\n }\n\n /**\n * Get all outpoints for the layer.\n */\n private getOutpoints(element: HTMLElement, inpoint: number): number[] {\n let outpoints = [inpoint + this.scene.layerDepth];\n\n if (element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]) {\n const values = element.dataset[PUSH_IN_TO_DATA_ATTRIBUTE]!.split(',');\n outpoints = values.map(value => parseInt(value.trim(), 10));\n } else if (this.options?.outpoints) {\n outpoints = this.options.outpoints;\n }\n\n return outpoints;\n }\n\n /**\n * Get the push-in speed for the layer.\n */\n private getSpeed(element: HTMLElement): number {\n let speed: number | null = null;\n\n if (element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]) {\n speed = parseInt(element.dataset[PUSH_IN_SPEED_DATA_ATTRIBUTE]!, 10);\n if (Number.isNaN(speed)) {\n speed = DEFAULT_SPEED;\n }\n } else if (this.options?.speed) {\n speed = this.options.speed;\n }\n\n return speed || DEFAULT_SPEED;\n }\n\n /**\n * Set the z-index of each layer so they overlap correctly.\n */\n setZIndex(total: number): void {\n this.element.style.zIndex = (total - this.index).toString();\n }\n\n /**\n * Reset all the layer parameters.\n *\n * This is used if the window is resized\n * and things need to be recalculated.\n */\n resetLayerParams(): void {\n this.params = {\n inpoint: this.getInpoint(this.ref.inpoints),\n outpoint: this.getOutpoint(this.ref.outpoints),\n speed: this.ref.speed,\n };\n }\n\n /**\n * Get the initial scale of the element at time of DOM load.\n */\n private getElementScaleX(element: HTMLElement): number {\n const transform = window\n .getComputedStyle(element)\n .getPropertyValue('transform');\n\n let scaleX = 1;\n if (transform && transform !== 'none') {\n const match = transform.match(/[matrix|scale]\\(([\\d,.\\s]+)/);\n if (match && match[1]) {\n const matrix = match[1].split(', ');\n scaleX = parseFloat(matrix[0]);\n }\n }\n\n return scaleX;\n }\n\n /**\n * Whether or not a layer should currently be zooming.\n */\n private isActive(): boolean {\n const { inpoint } = this.params;\n const { outpoint } = this.params;\n return (\n this.scene.pushin.scrollY >= inpoint &&\n this.scene.pushin.scrollY <= outpoint\n );\n }\n\n /**\n * Get the current inpoint for a layer,\n * depending on window breakpoint.\n */\n private getInpoint(inpoints: number[]): number {\n const { breakpoints } = this.scene.options;\n return inpoints[this.scene.getBreakpointIndex(breakpoints)] || inpoints[0];\n }\n\n /**\n * Get the current outpoint for a layer,\n * depending on window breakpoint.\n */\n private getOutpoint(outpoints: number[]): number {\n const { breakpoints } = this.scene.options;\n return (\n outpoints[this.scene.getBreakpointIndex(breakpoints)] || outpoints[0]\n );\n }\n\n /**\n * Get the scaleX value for the layer.\n */\n private getScaleValue(layer: PushInLayer): number {\n const distance = this.scene.pushin.scrollY - layer.params.inpoint;\n const speed = Math.min(layer.params.speed, 100) / 100;\n const delta = (distance * speed) / 100;\n\n return Math.max(layer.originalScale + delta, 0);\n }\n\n /**\n * Set element scale.\n */\n private setScale({ style }: HTMLElement, value: number): void {\n const scaleString = `scale(${value})`;\n style.webkitTransform = scaleString;\n (style as unknown as { mozTransform: string }).mozTransform = scaleString;\n (style as unknown as { msTransform: string }).msTransform = scaleString;\n (style as unknown as { oTransform: string }).oTransform = scaleString;\n style.transform = scaleString;\n }\n\n /**\n * Set CSS styles to control the effect on each layer.\n *\n * This will control the scale and opacity of the layer\n * as the user scrolls.\n */\n setLayerStyle(): void {\n let opacity = 0;\n const isFirst = this.index === 0;\n const isLast = this.index + 1 === this.scene.layers.length;\n const { inpoint } = this.params;\n const { outpoint } = this.params;\n\n if (isFirst && this.scene.pushin.scrollY < inpoint) {\n opacity = 1;\n } else if (isLast && this.scene.pushin.scrollY > outpoint) {\n opacity = 1;\n } else if (this.isActive()) {\n this.setScale(this.element, this.getScaleValue(this));\n\n let inpointDistance =\n Math.max(\n Math.min(\n this.scene.pushin.scrollY - inpoint,\n this.scene.transitionLength\n ),\n 0\n ) / this.scene.transitionLength;\n\n // Set opacity to 1 if its the first layer and it is active (no fading in here)\n if (isFirst) {\n inpointDistance = 1;\n }\n\n let outpointDistance =\n Math.max(\n Math.min(\n outpoint - this.scene.pushin.scrollY,\n this.scene.transitionLength\n ),\n 0\n ) / this.scene.transitionLength;\n\n // Set opacity to 1 if its the last layer and it is active (no fading out)\n if (isLast) {\n outpointDistance = 1;\n }\n\n opacity = Math.min(inpointDistance, outpointDistance);\n }\n\n this.element.style.opacity = opacity.toString();\n }\n}\n","import {\n PUSH_IN_FROM_DATA_ATTRIBUTE,\n PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE,\n PUSH_IN_DEFAULT_BREAKPOINTS,\n} from './constants';\nimport { PushInLayer } from './pushInLayer';\nimport { PushIn } from './pushin';\n\nimport { LayerOptions, SceneOptions } from './types';\n\nexport class PushInScene {\n private container: HTMLElement;\n public layers: PushInLayer[];\n public speedDelta: number;\n public transitionLength: number;\n public layerDepth: number;\n public options: SceneOptions;\n\n constructor(public pushin: PushIn) {\n const container =\n this.pushin.container.querySelector('.pushin-scene');\n\n if (container) {\n this.container = container;\n } else {\n this.container = document.createElement('div');\n this.container.classList.add('pushin-scene');\n\n this.container.innerHTML = this.pushin.container.innerHTML;\n this.pushin.container.innerHTML = '';\n this.pushin.container.appendChild(this.container);\n this.pushin.cleanupFns.push(() => {\n this.pushin.container.innerHTML = this.container.innerHTML;\n });\n }\n\n this.options = pushin.sceneOptions;\n\n this.speedDelta = this.options?.speedDelta || 100;\n this.layerDepth = this.options?.layerDepth || 1000;\n this.transitionLength = this.options?.transitionLength || 200;\n\n this.layers = [];\n\n this.setBreakpoints();\n this.getLayers();\n }\n\n /**\n * Set breakpoints for responsive design settings.\n */\n private setBreakpoints(): void {\n if (this.options?.breakpoints.length === 0) {\n this.options.breakpoints = [...PUSH_IN_DEFAULT_BREAKPOINTS];\n }\n\n if (this.container.dataset[PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE]) {\n this.options!.breakpoints = this.container.dataset[\n PUSH_IN_BREAKPOINTS_DATA_ATTRIBUTE\n ]!.split(',').map(breakpoint => parseInt(breakpoint.trim(), 10));\n }\n\n // Always include break point 0 for anything under first breakpoint\n this.options!.breakpoints.unshift(0);\n }\n\n /**\n * Find all layers on the page and store them with their parameters\n */\n private getLayers(): void {\n const layers = Array.from(\n this.container.getElementsByClassName('pushin-layer')\n );\n\n for (let index = 0; index < layers.length; index++) {\n const element = layers[index];\n let options = {};\n if (this.options?.layers && this.options.layers.length > index) {\n options = this!.options.layers[index];\n }\n\n const layer = new PushInLayer(element, index, this, options);\n this.layers.push(layer);\n\n layer.setZIndex(layers.length);\n }\n }\n\n /**\n * Get the array index of the current window breakpoint.\n */\n getBreakpointIndex(breakpoints: number[]): number {\n const searchIndex = breakpoints\n .reverse()\n .findIndex(bp => bp <= window.innerWidth);\n return searchIndex === -1 ? 0 : breakpoints.length - 1 - searchIndex;\n }\n\n getTop() {\n return this.container.getBoundingClientRect().top;\n }\n\n getInpoints(): number[] {\n let inpoints = [this.getTop()];\n\n if (this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]) {\n const pushInFrom = (\n this.container.dataset[PUSH_IN_FROM_DATA_ATTRIBUTE]\n );\n inpoints.push(parseInt(pushInFrom, 10));\n } else if (this.options?.inpoints?.length > 0) {\n inpoints = this.options.inpoints;\n }\n\n return inpoints;\n }\n}\n","import { PushInScene } from './pushInScene';\nimport { PushInLayer } from './pushInLayer';\n\nimport { PushInOptions, SceneOptions } from './types';\n\n/**\n * PushIn object\n *\n * Once new object is created, it will initialize itself and\n * bind events to begin interacting with dom.\n */\nexport class PushIn {\n private scene!: PushInScene;\n private pushinDebug?: HTMLElement;\n public sceneOptions: SceneOptions;\n\n public scrollY = 0;\n\n private readonly layers: PushInLayer[] = [];\n private readonly debug: boolean;\n\n private lastAnimationFrameId = -1;\n public cleanupFns: VoidFunction[] = [];\n\n constructor(public container: HTMLElement, options?: PushInOptions) {\n this.debug = options?.debug ?? false;\n\n this.sceneOptions = { breakpoints: [], inpoints: [] };\n if (options?.scene) {\n Object.assign(this.sceneOptions, options.scene);\n }\n if (options?.layers) {\n Object.assign(this.sceneOptions, options.layers);\n }\n }\n\n /**\n * Initialize the object to start everything up.\n */\n start(): void {\n this.scrollY = this.getScrollY();\n\n if (this.debug) {\n this.showDebugger();\n }\n\n if (this.container) {\n this.scene = new PushInScene(this);\n\n this.setScrollLength();\n\n if (typeof window !== 'undefined') {\n this.bindEvents();\n }\n\n // Set layer initial state\n this.toggleLayers();\n } else {\n // eslint-disable-next-line no-console\n console.error(\n 'No container element provided to pushIn.js. Effect will not be applied.'\n );\n }\n }\n\n /**\n * Does all necessary cleanups by removing event listeners.\n */\n destroy(): void {\n cancelAnimationFrame(this.lastAnimationFrameId);\n\n while (this.cleanupFns.length) {\n this.cleanupFns.pop()!();\n }\n }\n\n /**\n * If there is a window object,\n * get the current scroll position.\n *\n * Otherwise default to 0.\n */\n private getScrollY(): number {\n return typeof window !== 'undefined' ? window.scrollY : 0;\n }\n\n /**\n * Bind event listeners to watch for page load and user interaction.\n */\n bindEvents(): void {\n const onScroll = () => {\n this.scrollY = this.getScrollY();\n this.dolly();\n\n if (this.pushinDebug) {\n const content = this.pushinDebug?.querySelector(\n '.pushin-debug__content'\n );\n if (content) {\n content!.textContent = `Scroll position: ${Math.round(\n this.scrollY\n )}px`;\n }\n }\n };\n window.addEventListener('scroll', onScroll);\n this.cleanupFns.push(() => window.removeEventListener('scroll', onScroll));\n\n let resizeTimeout: number;\n const onResize = () => {\n clearTimeout(resizeTimeout);\n\n resizeTimeout = window.setTimeout(() => {\n this.scene.layers.forEach(layer => layer.resetLayerParams());\n this.setScrollLength();\n this.toggleLayers();\n }, 300);\n };\n window.addEventListener('resize', onResize);\n this.cleanupFns.push(() => window.removeEventListener('resize', onResize));\n }\n\n /**\n * Animation effect, mimicking a camera dolly on the webpage.\n */\n private dolly(): void {\n cancelAnimationFrame(this.lastAnimationFrameId);\n\n this.lastAnimationFrameId = requestAnimationFrame(() => {\n this.toggleLayers();\n });\n }\n\n /**\n * Show or hide layers and set their scale, depending on if active.\n */\n private toggleLayers(): void {\n this.scene.layers.forEach(layer => layer.setLayerStyle());\n }\n\n /**\n * Set the default container height based on a few factors:\n * 1. Number of layers present\n * 2. The transition length between layers\n * 3. The length of scrolling time during each layer\n *\n * If this calculation is smaller than the container's current height,\n * the current height will be used instead.\n */\n private setScrollLength(): void {\n const containerHeight = getComputedStyle(this.container).height.replace(\n 'px',\n ''\n );\n\n const transitions = (this.scene.layers.length - 1) * this.scene.speedDelta;\n const scrollLength =\n this.scene.layers.length *\n (this.scene.layerDepth + this.scene.transitionLength);\n\n this.container.style.height = `${Math.max(\n parseFloat(containerHeight),\n scrollLength - transitions\n )}px`;\n }\n\n /**\n * Show a debugging tool appended to the frontend of the page.\n * Can be used to determine best \"pushin-from\" and \"pushin-to\" values.\n */\n private showDebugger(): void {\n this.pushinDebug = document.createElement('div');\n this.pushinDebug.classList.add('pushin-debug');\n\n const scrollTitle = document.createElement('p');\n scrollTitle.innerText = 'Pushin.js Debugger';\n scrollTitle.classList.add('pushin-debug__title');\n\n const debuggerContent = document.createElement('div');\n debuggerContent.classList.add('pushin-debug__content');\n debuggerContent.innerText = `Scroll position: ${this.scrollY}px`;\n\n this.pushinDebug.appendChild(scrollTitle);\n this.pushinDebug.appendChild(debuggerContent);\n\n document.body.appendChild(this.pushinDebug);\n }\n}\n","import { PushIn } from './pushin';\nimport { PushInOptions } from './types';\n\ndeclare global {\n interface Window {\n pushInStart(options?: PushInOptions | string): void;\n }\n}\n\n/**\n * Helper function: Set up and start push-in effect on all elements\n * matching the provided selector.\n */\nconst pushInStart = (options?: PushInOptions): PushIn[] => {\n const pushInOptions = options ?? {};\n\n const elements = document.querySelectorAll('.pushin');\n const instances: PushIn[] = [];\n for (const element of elements) {\n const instance = new PushIn(element, pushInOptions);\n instance.start();\n\n instances.push(instance);\n }\n\n return instances;\n};\n\nif (typeof window !== 'undefined') {\n window.pushInStart = pushInStart;\n}\n"],"names":[],"mappings":";;;;;;;;;IAAO,MAAM,aAAa,GAAG,CAAC,CAAC;IAE/B;IACA;IACO,MA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,CAAc,SAAS,CAAC,CAAC;QACnE,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACpD,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEjB,QAAA,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,KAAA;IAED,IAAA,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,IAAA,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IAClC;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/umd/pushin.min.js b/dist/umd/pushin.min.js index 76ee24d..3aea62c 100644 --- a/dist/umd/pushin.min.js +++ b/dist/umd/pushin.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pushin={})}(this,(function(t){"use strict";class e{constructor(t,e){var s,n,i;this.container=t,this.scrollY=0,this.scrollEnd=null,this.touchStart=null,this.pageHeight=null,this.layers=[],this.speedDelta=100,this.transitionLength=200,this.layerDepth=1e3,this.lastAnimationFrameId=-1,this.cleanupFns=[],this.debug=null!==(s=null==e?void 0:e.debug)&&void 0!==s&&s,this.layerOptions=null!==(n=null==e?void 0:e.layers)&&void 0!==n?n:[],this.sceneOptions=null!==(i=null==e?void 0:e.scene)&&void 0!==i?i:{breakpoints:[],inpoints:[]}}start(){this.container?(this.scrollY=this.getScrollY(),this.debug&&this.showDebugger(),this.addScene(),this.setBreakpoints(),this.getLayers(),this.setScrollLength(),"undefined"!=typeof window&&this.bindEvents(),this.toggleLayers()):console.error("No container element provided to pushIn.js. Effect will not be applied.")}destroy(){for(cancelAnimationFrame(this.lastAnimationFrameId);this.cleanupFns.length;)this.cleanupFns.pop()()}getScrollY(){return"undefined"!=typeof window?window.scrollY:0}addScene(){const t=this.container.querySelector(".pushin-scene");t?this.scene=t:(this.scene=document.createElement("div"),this.scene.classList.add("pushin-scene"),this.scene.innerHTML=this.container.innerHTML,this.container.innerHTML="",this.container.appendChild(this.scene),this.cleanupFns.push((()=>this.container.removeChild(this.scene))))}setBreakpoints(){0===this.sceneOptions.breakpoints.length&&(this.sceneOptions.breakpoints=[768,1440,1920]),this.scene.dataset.pushinBreakpoints&&(this.sceneOptions.breakpoints=this.scene.dataset.pushinBreakpoints.split(",").map((t=>parseInt(t.trim(),10)))),this.sceneOptions.breakpoints.unshift(0)}getLayers(){const t=Array.from(this.container.getElementsByClassName("pushin-layer"));for(let e=0;eparseInt(t.trim(),10)));else if(null===(s=this.layerOptions[e])||void 0===s?void 0:s.inpoints)o=this.layerOptions[e].inpoints;else if(0===e&&this.scene.dataset.pushinFrom)o=this.scene.dataset.pushinFrom.split(",").map((t=>parseInt(t.trim(),10)));else if(0===e&&(null===(n=this.sceneOptions)||void 0===n?void 0:n.inpoints.length)>0)o=this.sceneOptions.inpoints;else if(e>0){const{outpoint:t}=this.layers[e-1].params;o=[t-this.speedDelta]}return o}getOutpoints(t,e,s){var n;let i=[e+this.layerDepth];if(t.dataset.pushinTo){i=t.dataset.pushinTo.split(",").map((t=>parseInt(t.trim(),10)))}else(null===(n=this.layerOptions[s])||void 0===n?void 0:n.outpoints)&&(i=this.layerOptions[s].outpoints);return i}getSpeed(t,e){var s;let n=null;return t.dataset.pushinSpeed?(n=parseInt(t.dataset.pushinSpeed,10),Number.isNaN(n)&&(n=8)):"number"==typeof e&&(null===(s=this.layerOptions[e])||void 0===s?void 0:s.speed)&&(n=this.layerOptions[e].speed),n||8}getBreakpointIndex(){const t="undefined"!=typeof window?window.innerWidth:0,e=this.sceneOptions.breakpoints.reverse().findIndex((e=>e<=t));return-1===e?0:this.sceneOptions.breakpoints.length-1-e}setZIndex(t,e){t.element.style.zIndex=(e-t.index).toString()}bindEvents(){const t=()=>{this.scrollY=this.getScrollY(),this.dolly()};let e;window.addEventListener("scroll",t),this.cleanupFns.push((()=>window.removeEventListener("scroll",t)));const s=()=>{clearTimeout(e),e=window.setTimeout((()=>{this.resetLayerParams(),this.setScrollLength(),this.toggleLayers()}),300)};window.addEventListener("resize",s),this.cleanupFns.push((()=>window.removeEventListener("resize",s))),this.pushinDebug&&window.addEventListener("scroll",(()=>{var t;const e="undefined"!=typeof window?window.scrollY:0,s=null===(t=this.pushinDebug)||void 0===t?void 0:t.querySelector(".pushin-debug__content");s&&(s.textContent=`Scroll position: ${Math.round(e)}px`)}))}resetLayerParams(){this.layers.forEach((t=>{t.params={inpoint:this.getInpoint(t.ref.inpoints),outpoint:this.getOutpoint(t.ref.outpoints),speed:t.ref.speed}}))}getElementScaleX(t){const e=window.getComputedStyle(t).getPropertyValue("transform");let s=1;if(e&&"none"!==e){const t=e.match(/[matrix|scale]\(([\d,.\s]+)/);if(t&&t[1]){const e=t[1].split(", ");s=parseFloat(e[0])}}return s}dolly(){cancelAnimationFrame(this.lastAnimationFrameId),this.lastAnimationFrameId=requestAnimationFrame((()=>{this.toggleLayers()}))}toggleLayers(){this.layers.forEach((t=>this.setLayerStyle(t)))}isActive(t){const{inpoint:e}=t.params,{outpoint:s}=t.params;return this.scrollY>=e&&this.scrollY<=s}getInpoint(t){return t[this.getBreakpointIndex()]||t[0]}getOutpoint(t){return t[this.getBreakpointIndex()]||t[0]}getScaleValue(t){const e=(this.scrollY-t.params.inpoint)*(Math.min(t.params.speed,100)/100)/100;return Math.max(t.originalScale+e,0)}setScale({style:t},e){const s=`scale(${e})`;t.webkitTransform=s,t.mozTransform=s,t.msTransform=s,t.oTransform=s,t.transform=s}setLayerStyle(t){let e=0;const s=0===t.index,n=t.index+1===this.layers.length,{inpoint:i}=t.params,{outpoint:o}=t.params;if(s&&this.scrollYo)e=1;else if(this.isActive(t)){this.setScale(t.element,this.getScaleValue(t));let r=Math.max(Math.min(this.scrollY-i,this.transitionLength),0)/this.transitionLength;s&&(r=1);let a=Math.max(Math.min(o-this.scrollY,this.transitionLength),0)/this.transitionLength;n&&(a=1),e=Math.min(r,a)}t.element.style.opacity=e.toString()}setScrollLength(){const t=getComputedStyle(this.container).height.replace("px",""),e=(this.layers.length-1)*this.speedDelta,s=this.layers.length*(this.layerDepth+this.transitionLength);this.container.style.height=`${Math.max(parseFloat(t),s-e)}px`}showDebugger(){this.pushinDebug=document.createElement("div"),this.pushinDebug.classList.add("pushin-debug");const t=document.createElement("p");t.innerText="Pushin.js Debugger",t.classList.add("pushin-debug__title");const e="undefined"!=typeof window?window.scrollY:0,s=document.createElement("div");s.classList.add("pushin-debug__content"),s.innerText=`Scroll position: ${e}px`,this.pushinDebug.appendChild(t),this.pushinDebug.appendChild(s),document.body.appendChild(this.pushinDebug)}}const s=t=>{const s=null!=t?t:{},n=document.querySelectorAll(".pushin"),i=[];for(const t of n){const n=new e(t,s);n.start(),i.push(n)}return i};"undefined"!=typeof window&&(window.pushInStart=s),t.PushIn=e,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pushin={})}(this,(function(t){"use strict";const e=[768,1440,1920];class s{constructor(t,e,s,n){this.element=t,this.index=e,this.scene=s,this.options=n;const i=this.getInpoints(this.element,this.index),o=this.getOutpoints(this.element,i[0]),h=this.getSpeed(this.element);this.originalScale=this.getElementScaleX(t),this.ref={inpoints:i,outpoints:o,speed:h},this.params={inpoint:this.getInpoint(i),outpoint:this.getOutpoint(o),speed:h}}getInpoints(t,e){var s;let n=[this.scene.getTop()];if(t.dataset.pushinFrom)n=t.dataset.pushinFrom.split(",").map((t=>parseInt(t.trim(),10)));else if(null===(s=this.options)||void 0===s?void 0:s.inpoints)n=this.options.inpoints;else if(0===e)n=this.scene.getInpoints();else if(e>0){const{outpoint:t}=this.scene.layers[e-1].params;n=[t-this.scene.speedDelta]}return n}getOutpoints(t,e){var s;let n=[e+this.scene.layerDepth];if(t.dataset.pushinTo){n=t.dataset.pushinTo.split(",").map((t=>parseInt(t.trim(),10)))}else(null===(s=this.options)||void 0===s?void 0:s.outpoints)&&(n=this.options.outpoints);return n}getSpeed(t){var e;let s=null;return t.dataset.pushinSpeed?(s=parseInt(t.dataset.pushinSpeed,10),Number.isNaN(s)&&(s=8)):(null===(e=this.options)||void 0===e?void 0:e.speed)&&(s=this.options.speed),s||8}setZIndex(t){this.element.style.zIndex=(t-this.index).toString()}resetLayerParams(){this.params={inpoint:this.getInpoint(this.ref.inpoints),outpoint:this.getOutpoint(this.ref.outpoints),speed:this.ref.speed}}getElementScaleX(t){const e=window.getComputedStyle(t).getPropertyValue("transform");let s=1;if(e&&"none"!==e){const t=e.match(/[matrix|scale]\(([\d,.\s]+)/);if(t&&t[1]){const e=t[1].split(", ");s=parseFloat(e[0])}}return s}isActive(){const{inpoint:t}=this.params,{outpoint:e}=this.params;return this.scene.pushin.scrollY>=t&&this.scene.pushin.scrollY<=e}getInpoint(t){const{breakpoints:e}=this.scene.options;return t[this.scene.getBreakpointIndex(e)]||t[0]}getOutpoint(t){const{breakpoints:e}=this.scene.options;return t[this.scene.getBreakpointIndex(e)]||t[0]}getScaleValue(t){const e=(this.scene.pushin.scrollY-t.params.inpoint)*(Math.min(t.params.speed,100)/100)/100;return Math.max(t.originalScale+e,0)}setScale({style:t},e){const s=`scale(${e})`;t.webkitTransform=s,t.mozTransform=s,t.msTransform=s,t.oTransform=s,t.transform=s}setLayerStyle(){let t=0;const e=0===this.index,s=this.index+1===this.scene.layers.length,{inpoint:n}=this.params,{outpoint:i}=this.params;if(e&&this.scene.pushin.scrollYi)t=1;else if(this.isActive()){this.setScale(this.element,this.getScaleValue(this));let o=Math.max(Math.min(this.scene.pushin.scrollY-n,this.scene.transitionLength),0)/this.scene.transitionLength;e&&(o=1);let h=Math.max(Math.min(i-this.scene.pushin.scrollY,this.scene.transitionLength),0)/this.scene.transitionLength;s&&(h=1),t=Math.min(o,h)}this.element.style.opacity=t.toString()}}class n{constructor(t){var e,s,n;this.pushin=t;const i=this.pushin.container.querySelector(".pushin-scene");i?this.container=i:(this.container=document.createElement("div"),this.container.classList.add("pushin-scene"),this.container.innerHTML=this.pushin.container.innerHTML,this.pushin.container.innerHTML="",this.pushin.container.appendChild(this.container),this.pushin.cleanupFns.push((()=>{this.pushin.container.innerHTML=this.container.innerHTML}))),this.options=t.sceneOptions,this.speedDelta=(null===(e=this.options)||void 0===e?void 0:e.speedDelta)||100,this.layerDepth=(null===(s=this.options)||void 0===s?void 0:s.layerDepth)||1e3,this.transitionLength=(null===(n=this.options)||void 0===n?void 0:n.transitionLength)||200,this.layers=[],this.setBreakpoints(),this.getLayers()}setBreakpoints(){var t;0===(null===(t=this.options)||void 0===t?void 0:t.breakpoints.length)&&(this.options.breakpoints=[...e]),this.container.dataset.pushinBreakpoints&&(this.options.breakpoints=this.container.dataset.pushinBreakpoints.split(",").map((t=>parseInt(t.trim(),10)))),this.options.breakpoints.unshift(0)}getLayers(){var t;const e=Array.from(this.container.getElementsByClassName("pushin-layer"));for(let n=0;nn&&(o=this.options.layers[n]);const h=new s(i,n,this,o);this.layers.push(h),h.setZIndex(e.length)}}getBreakpointIndex(t){const e=t.reverse().findIndex((t=>t<=window.innerWidth));return-1===e?0:t.length-1-e}getTop(){return this.container.getBoundingClientRect().top}getInpoints(){var t,e;let s=[this.getTop()];if(this.container.dataset.pushinFrom){const t=this.container.dataset.pushinFrom;s.push(parseInt(t,10))}else(null===(e=null===(t=this.options)||void 0===t?void 0:t.inpoints)||void 0===e?void 0:e.length)>0&&(s=this.options.inpoints);return s}}class i{constructor(t,e){var s;this.container=t,this.scrollY=0,this.layers=[],this.lastAnimationFrameId=-1,this.cleanupFns=[],this.debug=null!==(s=null==e?void 0:e.debug)&&void 0!==s&&s,this.sceneOptions={breakpoints:[],inpoints:[]},(null==e?void 0:e.scene)&&Object.assign(this.sceneOptions,e.scene),(null==e?void 0:e.layers)&&Object.assign(this.sceneOptions,e.layers)}start(){this.scrollY=this.getScrollY(),this.debug&&this.showDebugger(),this.container?(this.scene=new n(this),this.setScrollLength(),"undefined"!=typeof window&&this.bindEvents(),this.toggleLayers()):console.error("No container element provided to pushIn.js. Effect will not be applied.")}destroy(){for(cancelAnimationFrame(this.lastAnimationFrameId);this.cleanupFns.length;)this.cleanupFns.pop()()}getScrollY(){return"undefined"!=typeof window?window.scrollY:0}bindEvents(){const t=()=>{var t;if(this.scrollY=this.getScrollY(),this.dolly(),this.pushinDebug){const e=null===(t=this.pushinDebug)||void 0===t?void 0:t.querySelector(".pushin-debug__content");e&&(e.textContent=`Scroll position: ${Math.round(this.scrollY)}px`)}};let e;window.addEventListener("scroll",t),this.cleanupFns.push((()=>window.removeEventListener("scroll",t)));const s=()=>{clearTimeout(e),e=window.setTimeout((()=>{this.scene.layers.forEach((t=>t.resetLayerParams())),this.setScrollLength(),this.toggleLayers()}),300)};window.addEventListener("resize",s),this.cleanupFns.push((()=>window.removeEventListener("resize",s)))}dolly(){cancelAnimationFrame(this.lastAnimationFrameId),this.lastAnimationFrameId=requestAnimationFrame((()=>{this.toggleLayers()}))}toggleLayers(){this.scene.layers.forEach((t=>t.setLayerStyle()))}setScrollLength(){const t=getComputedStyle(this.container).height.replace("px",""),e=(this.scene.layers.length-1)*this.scene.speedDelta,s=this.scene.layers.length*(this.scene.layerDepth+this.scene.transitionLength);this.container.style.height=`${Math.max(parseFloat(t),s-e)}px`}showDebugger(){this.pushinDebug=document.createElement("div"),this.pushinDebug.classList.add("pushin-debug");const t=document.createElement("p");t.innerText="Pushin.js Debugger",t.classList.add("pushin-debug__title");const e=document.createElement("div");e.classList.add("pushin-debug__content"),e.innerText=`Scroll position: ${this.scrollY}px`,this.pushinDebug.appendChild(t),this.pushinDebug.appendChild(e),document.body.appendChild(this.pushinDebug)}}const o=t=>{const e=null!=t?t:{},s=document.querySelectorAll(".pushin"),n=[];for(const t of s){const s=new i(t,e);s.start(),n.push(s)}return n};"undefined"!=typeof window&&(window.pushInStart=o),t.PushIn=i,Object.defineProperty(t,"__esModule",{value:!0})}));