mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 14:59:39 +00:00
V3 UI - Tabs & Menu rework (#4374)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
27
src/utils/mouseDownUtil.ts
Normal file
27
src/utils/mouseDownUtil.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useEventListener } from '@vueuse/core'
|
||||
|
||||
export const whileMouseDown = (
|
||||
elementOrEvent: HTMLElement | Event,
|
||||
callback: (iteration: number) => void,
|
||||
interval: number = 30
|
||||
) => {
|
||||
const element =
|
||||
elementOrEvent instanceof HTMLElement
|
||||
? elementOrEvent
|
||||
: (elementOrEvent.target as HTMLElement)
|
||||
|
||||
let iteration = 0
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
callback(iteration++)
|
||||
}, interval)
|
||||
|
||||
const dispose = useEventListener(element, 'mouseup', () => {
|
||||
clearInterval(intervalId)
|
||||
dispose()
|
||||
})
|
||||
|
||||
return {
|
||||
dispose
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user