add stack update the refresh components

This commit is contained in:
Spedon
2023-03-28 18:55:53 +08:00
parent 404c0870c7
commit 5e311692f4
2 changed files with 34 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { duper } from './utils'
import { setStackDepth } from './desktop'
// get threshold display element
const thresholdDisp = document.getElementsByClassName('thid').item(0) as HTMLSpanElement
@@ -8,11 +9,17 @@ const threshold: number[] = [0, 40, 80, 120, 160, 200]
export const thresholdSensitivityArray: number[] = [100, 40, 18, 14, 9, 5]
export let thresholdIndex: number = 2
export const stackDepthArray: number[] = [15, 8, 5, 5, 5, 5]
// update inner text of threshold display element
const thresholdUpdate = (): void => {
thresholdDisp.innerText = duper(threshold[thresholdIndex])
}
const stackDepthUpdate = (): void => {
setStackDepth(stackDepthArray[thresholdIndex])
}
// threshold control initialization
export const thresholdCtlInit = (): void => {
thresholdUpdate()
@@ -23,6 +30,7 @@ export const thresholdCtlInit = (): void => {
if (thresholdIndex > 0) {
thresholdIndex--
thresholdUpdate()
stackDepthUpdate()
}
},
{ passive: true }
@@ -35,6 +43,7 @@ export const thresholdCtlInit = (): void => {
if (thresholdIndex < 5) {
thresholdIndex++
thresholdUpdate()
stackDepthUpdate()
}
},
{ passive: true }