| 6 | } |
| 7 | |
| 8 | class TipHandler { |
| 9 | tip: TipOptions | null = null; |
| 10 | |
| 11 | private showDelay: number | null = null; |
| 12 | |
| 13 | private hideDelay: number | null = null; |
| 14 | |
| 15 | private emitter: IEventBus = createModuleEventBus('TipHandler'); |
| 16 | |
| 17 | setTarget(target: HTMLElement) { |
| 18 | const tip = findTip(target); |
| 19 | if (tip) { |
| 20 | if (this.tip) { |
| 21 | // the some target should return |
| 22 | if ((this.tip as any).target === (tip as any).target) { |
| 23 | this.tip = tip; |
| 24 | return; |
| 25 | } |
| 26 | // not show already, reset show delay |
| 27 | if (this.showDelay) { |
| 28 | clearTimeout(this.showDelay); |
| 29 | this.showDelay = null; |
| 30 | this.tip = null; |
| 31 | } else { |
| 32 | if (this.hideDelay) { |
| 33 | clearTimeout(this.hideDelay); |
| 34 | this.hideDelay = null; |
| 35 | } |
| 36 | this.tip = tip; |
| 37 | this.emitter.emit('tipchange'); |
| 38 | return; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | this.tip = tip; |
| 43 | if (this.hideDelay) { |
| 44 | clearTimeout(this.hideDelay); |
| 45 | this.hideDelay = null; |
| 46 | this.emitter.emit('tipchange'); |
| 47 | } else { |
| 48 | this.showDelay = setTimeout(() => { |
| 49 | this.showDelay = null; |
| 50 | this.emitter.emit('tipchange'); |
| 51 | }, 350) as any; |
| 52 | } |
| 53 | } else { |
| 54 | if (this.showDelay) { |
| 55 | clearTimeout(this.showDelay); |
| 56 | this.showDelay = null; |
| 57 | } else { |
| 58 | this.hideDelay = setTimeout(() => { |
| 59 | this.hideDelay = null; |
| 60 | }, 100) as any; |
| 61 | } |
| 62 | this.tip = null; |
| 63 | |
| 64 | this.emitter.emit('tipchange'); |
| 65 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…