mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-21 05:29:31 -07:00
move footerUpdate function to overlay.ts and combine it with recenter function
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import { footerHeightUpdateInit } from './utils'
|
|
||||||
import { imgIndexSpanUpdate } from './indexDisp'
|
import { imgIndexSpanUpdate } from './indexDisp'
|
||||||
import { trackMouseInit } from './trackMouse'
|
import { trackMouseInit } from './trackMouse'
|
||||||
import { thresholdCtlInit } from './thresholdCtl'
|
import { thresholdCtlInit } from './thresholdCtl'
|
||||||
import { imagesArrayLen } from './dataFetch'
|
import { imagesArrayLen } from './dataFetch'
|
||||||
|
import { vwRefreshInit } from './overlay'
|
||||||
|
|
||||||
function init(): void {
|
function init(): void {
|
||||||
footerHeightUpdateInit()
|
vwRefreshInit()
|
||||||
imgIndexSpanUpdate(0, imagesArrayLen)
|
imgIndexSpanUpdate(0, imagesArrayLen)
|
||||||
thresholdCtlInit()
|
thresholdCtlInit()
|
||||||
trackMouseInit()
|
trackMouseInit()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { delay, removeAllEventListeners, layersPosSet } from './utils'
|
import { delay, removeAllEventListeners, layersPosSet, center } from './utils'
|
||||||
import { posArray, layers, handleOnMove } from './trackMouse'
|
import { posArray, layers, handleOnMove } from './trackMouse'
|
||||||
|
|
||||||
// get components of overlay
|
// get components of overlay
|
||||||
@@ -84,3 +84,21 @@ function setListener(): void {
|
|||||||
{ passive: true }
|
{ passive: true }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function vwRefreshInit(): void {
|
||||||
|
window.addEventListener(
|
||||||
|
'resize',
|
||||||
|
() => {
|
||||||
|
// reset footer height
|
||||||
|
const r = document.querySelector(':root') as HTMLStyleElement
|
||||||
|
if (window.innerWidth > 768) {
|
||||||
|
r.style.setProperty('--footer-height', '38px')
|
||||||
|
} else {
|
||||||
|
r.style.setProperty('--footer-height', '31px')
|
||||||
|
}
|
||||||
|
// recenter image
|
||||||
|
center(layers[4])
|
||||||
|
},
|
||||||
|
{ passive: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,18 +61,3 @@ export const center = (e: HTMLDivElement): void => {
|
|||||||
e.style.top = 'calc((100% - 31px) / 2 + 31px)'
|
e.style.top = 'calc((100% - 31px) / 2 + 31px)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function footerHeightUpdateInit(): void {
|
|
||||||
window.addEventListener(
|
|
||||||
'resize',
|
|
||||||
() => {
|
|
||||||
const r = document.querySelector(':root') as HTMLElement
|
|
||||||
if (window.innerWidth > 768) {
|
|
||||||
r.style.setProperty('--footer-height', '38px')
|
|
||||||
} else {
|
|
||||||
r.style.setProperty('--footer-height', '31px')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ passive: true }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user