change function style to const

This commit is contained in:
Spedon
2023-03-16 20:18:11 +08:00
parent 96b75abc7d
commit 19e89db88a
6 changed files with 17 additions and 17 deletions

View File

@@ -87,7 +87,7 @@ async function enterOverlay(): Promise<void> {
}
// initialization
export function trackMouseInit(): void {
export const trackMouseInit = (): void => {
window.addEventListener('mousemove', handleOnMove)
layers[4].addEventListener(
'click',
@@ -100,12 +100,12 @@ export function trackMouseInit(): void {
)
}
export function globalIndexDec(): void {
export const globalIndexDec = (): void => {
globalIndex--
preloader(globalIndex)
}
export function globalIndexInc(): void {
export const globalIndexInc = (): void => {
globalIndex++
preloader(globalIndex)
}

View File

@@ -3,7 +3,7 @@ import { preloadImage, calcImageIndex } from './utils'
let lastIndex: number = 0
export function preloader(index: number): void {
export const preloader = (index: number): void => {
if (lastIndex === index) {
for (let i: number = -2; i <= 1; i++)
preloadImage(imagesArray[calcImageIndex(index + i, imagesArrayLen)].url)

View File

@@ -1,7 +1,7 @@
import { duper } from './utils'
// update index of displaying image
export function imgIndexSpanUpdate(numOne: number, numTwo: number): void {
export const imgIndexSpanUpdate = (numOne: number, numTwo: number): void => {
// footer index number display module
const footerIndexDisp = document.getElementsByClassName('ftid')
const numOneString: string = duper(numOne)

View File

@@ -6,7 +6,7 @@ import { vwRefreshInit } from './overlay'
import { preloader } from './imageCache'
import { getDeviceType } from './utils'
function desktopInit(): void {
const desktopInit = (): void => {
preloader(0)
vwRefreshInit()
imgIndexSpanUpdate(0, imagesArrayLen)
@@ -14,7 +14,7 @@ function desktopInit(): void {
trackMouseInit()
}
function mobileInit(): void {
const mobileInit = (): void => {
console.log('mobile')
}

View File

@@ -28,7 +28,7 @@ const cursor = document
.item(0) as HTMLDivElement
// set cursor text
function setCursorText(text: string): void {
const setCursorText = (text: string): void => {
cursor.innerText = text
}
@@ -39,7 +39,7 @@ const overlayCursor = (e: MouseEvent): void => {
}
// disable listeners
function disableListener(): void {
const disableListener = (): void => {
window.removeEventListener('mousemove', overlayCursor)
closeSection = removeAllEventListeners(closeSection)
prevSection = removeAllEventListeners(prevSection)
@@ -47,13 +47,13 @@ function disableListener(): void {
}
// enable overlay
export function overlayEnable(): void {
export const overlayEnable = (): void => {
overlay.style.zIndex = '7'
setListener()
}
// disable overlay
export function overlayDisable(): void {
export const overlayDisable = (): void => {
overlay.style.zIndex = '-1'
setCursorText('')
disableListener()
@@ -76,14 +76,14 @@ async function handleCloseClick(): Promise<void> {
window.addEventListener('mousemove', handleOnMove)
}
function handlePrevClick(): void {
const handlePrevClick = (): void => {
globalIndexDec()
const imgIndex = calcImageIndex(globalIndex, imagesArrayLen)
FIFO(createImgElement(imagesArray[imgIndex], false).image, layers)
imgIndexSpanUpdate(imgIndex + 1, imagesArrayLen)
}
function handleNextClick(): void {
const handleNextClick = (): void => {
globalIndexInc()
const imgIndex = calcImageIndex(globalIndex, imagesArrayLen)
FIFO(createImgElement(imagesArray[imgIndex], false).image, layers)
@@ -91,7 +91,7 @@ function handleNextClick(): void {
}
// set event listener
function setListener(): void {
const setListener = (): void => {
window.addEventListener('mousemove', overlayCursor, { passive: true })
closeSection.addEventListener(
'mouseover',
@@ -137,7 +137,7 @@ function setListener(): void {
)
}
export function vwRefreshInit(): void {
export const vwRefreshInit = (): void => {
window.addEventListener(
'resize',
() => {

View File

@@ -9,12 +9,12 @@ export const thresholdSensitivityArray: number[] = [100, 40, 18, 14, 9, 5]
export let thresholdIndex: number = 2
// update inner text of threshold display element
function thresholdUpdate(): void {
const thresholdUpdate = (): void => {
thresholdDisp.innerText = duper(threshold[thresholdIndex])
}
// threshold control initialization
export function thresholdCtlInit(): void {
export const thresholdCtlInit = (): void => {
thresholdUpdate()
const dec = document.getElementById('thresholdDec') as HTMLButtonElement
dec.addEventListener(