mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-11-29 17:58:08 +08:00
chore(utils): improve setTimeout type (#17763)
* chore(utils): improve setTimeout type * revert
This commit is contained in:
parent
48dfe3a69a
commit
785761ab89
@ -18,7 +18,7 @@ import type { UseNamespaceReturn } from '@element-plus/hooks'
|
||||
import type { LoadingOptionsResolved } from './types'
|
||||
|
||||
export function createLoadingComponent(options: LoadingOptionsResolved) {
|
||||
let afterLeaveTimer: number
|
||||
let afterLeaveTimer: ReturnType<typeof setTimeout>
|
||||
// IMPORTANT NOTE: this is only a hacking way to expose the injections on an
|
||||
// instance, DO NOT FOLLOW this pattern in your own code.
|
||||
const afterLeaveFlag = ref(false)
|
||||
@ -60,7 +60,7 @@ export function createLoadingComponent(options: LoadingOptionsResolved) {
|
||||
afterLeaveFlag.value = true
|
||||
clearTimeout(afterLeaveTimer)
|
||||
|
||||
afterLeaveTimer = window.setTimeout(handleAfterLeave, 400)
|
||||
afterLeaveTimer = setTimeout(handleAfterLeave, 400)
|
||||
data.visible = false
|
||||
|
||||
options.closed?.()
|
||||
|
@ -5,13 +5,13 @@ import type { Ref } from 'vue'
|
||||
export const useThrottleRender = (loading: Ref<boolean>, throttle = 0) => {
|
||||
if (throttle === 0) return loading
|
||||
const throttled = ref(false)
|
||||
let timeoutHandle = 0
|
||||
let timeoutHandle: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
const dispatchThrottling = () => {
|
||||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle)
|
||||
}
|
||||
timeoutHandle = window.setTimeout(() => {
|
||||
timeoutHandle = setTimeout(() => {
|
||||
throttled.value = loading.value
|
||||
}, throttle)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user