Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

TooltipManager.ts 602B

123456789101112131415161718192021222324252627
  1. class TooltipManager {
  2. private activeCloser: (() => void) | null = null
  3. register(closeFn: () => void) {
  4. if (this.activeCloser)
  5. this.activeCloser()
  6. this.activeCloser = closeFn
  7. }
  8. clear(closeFn: () => void) {
  9. if (this.activeCloser === closeFn)
  10. this.activeCloser = null
  11. }
  12. /**
  13. * Closes the currently active tooltip by calling its closer function
  14. * and clearing the reference to it
  15. */
  16. closeActiveTooltip() {
  17. if (this.activeCloser) {
  18. this.activeCloser()
  19. this.activeCloser = null
  20. }
  21. }
  22. }
  23. export const tooltipManager = new TooltipManager()