UNPKG

@limetech/lime-elements

Version:
20 lines (19 loc) 608 B
const DEFAULT_DELAY_FOR_SHOWING = 500; export class TooltipTimer { constructor(showCallback, hideCallback, delayForShowing = DEFAULT_DELAY_FOR_SHOWING) { this.timerHandle = null; this.showCallback = showCallback; this.hideCallback = hideCallback; this.delayForShowing = delayForShowing; } showAfterDelay() { if (!this.timerHandle) { this.timerHandle = setTimeout(this.showCallback, this.delayForShowing); } } hide() { clearTimeout(this.timerHandle); this.timerHandle = null; this.hideCallback(); } }