From 1d8c3af09f153fad0eb8a21f3dd5115fa46ddefc Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Sun, 11 Jun 2023 14:46:26 +0100 Subject: [PATCH] Refactor highlight --- src/driver.ts | 1 - src/highlight.ts | 2 +- src/state.ts | 4 ++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/driver.ts b/src/driver.ts index 021edc6..cc64ee5 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -34,7 +34,6 @@ export function driver(options: Config = {}) { initEvents(); - // Register hooks listen("overlayClick", handleClose); listen("escape", handleClose); } diff --git a/src/highlight.ts b/src/highlight.ts index 834c036..16fac07 100644 --- a/src/highlight.ts +++ b/src/highlight.ts @@ -64,7 +64,7 @@ function transferHighlight(from: Element, to: Element) { // If it's the first time we're highlighting an element, we show // the popover immediately. Otherwise, we wait for the animation // to finish before showing the popover. - const hasDelayedPopover = to && (!from || from !== to); + const hasDelayedPopover = !from || from !== to; hidePopover(); diff --git a/src/state.ts b/src/state.ts index 0ac8490..cf6b7f1 100644 --- a/src/state.ts +++ b/src/state.ts @@ -2,9 +2,13 @@ import { StageDefinition } from "./stage"; import { PopoverDOM } from "./popover"; export type State = { + // Whether driver is initialized or not isInitialized?: boolean; + + // Used to bounce the resize event resizeTimeout?: number; + // Used while transitioning between stages previousHighlight?: Element; activeHighlight?: Element; transitionCallback?: () => void;