From 38d1a8ab387adb5a797cdba88f707f32c16d7521 Mon Sep 17 00:00:00 2001 From: Spedon Date: Tue, 14 Mar 2023 01:57:56 +0800 Subject: [PATCH] move all interfaces to utils.ts --- assets/ts/dataFetch.ts | 7 +------ assets/ts/trackMouse.ts | 7 +------ assets/ts/utils.ts | 12 ++++++++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/assets/ts/dataFetch.ts b/assets/ts/dataFetch.ts index 81adbc7..07db65d 100644 --- a/assets/ts/dataFetch.ts +++ b/assets/ts/dataFetch.ts @@ -1,9 +1,4 @@ -interface ImageData { - index: string - url: string - imgH: string - imgW: string -} +import { type ImageData } from './utils' // fetch images info from JSON const imageArrayElement = document.getElementById('images_array') as HTMLScriptElement diff --git a/assets/ts/trackMouse.ts b/assets/ts/trackMouse.ts index 78dfecc..8ecb46d 100644 --- a/assets/ts/trackMouse.ts +++ b/assets/ts/trackMouse.ts @@ -1,14 +1,9 @@ import { overlayEnable } from './overlay' -import { posCache, FIFO, layersPosSet, center } from './utils' +import { posCache, FIFO, layersPosSet, center, type position } from './utils' import { thresholdSensitivityArray, thresholdIndex } from './thresholdCtl' import { imgIndexSpanUpdate } from './indexDisp' import { imagesArrayLen, imagesArray } from './dataFetch' -export interface position { - x: number - y: number -} - // get layer divs const layer5 = document.getElementById('layer5') as HTMLDivElement const layer4 = document.getElementById('layer4') as HTMLDivElement diff --git a/assets/ts/utils.ts b/assets/ts/utils.ts index 3b17e6e..a9d865a 100644 --- a/assets/ts/utils.ts +++ b/assets/ts/utils.ts @@ -1,3 +1,15 @@ +export interface ImageData { + index: string + url: string + imgH: string + imgW: string +} + +export interface position { + x: number + y: number +} + // cache a xy position to array export const posCache = (x: number, y: number, xyArray: string[][]): void => { // pop element if length surpass limitation