kamrify commited on
Commit
3b225cb
·
1 Parent(s): 836d49f

Improve popup rendering

Browse files
Files changed (1) hide show
  1. src/highlight.ts +8 -12
src/highlight.ts CHANGED
@@ -80,14 +80,7 @@ function transferHighlight(from: Element, to: Element, toStep: DriveStep) {
80
  const isNextOrPrevDummyElement = to.id === "driver-dummy-element" || from.id === "driver-dummy-element";
81
 
82
  const hasDelayedPopover = !isFirstHighlight && (hasNoPreviousPopover || isNextOrPrevDummyElement);
83
-
84
- console.log("--------------------");
85
- console.log("from", from);
86
- console.log("to", to);
87
- console.log("hasDelayedPopover", hasDelayedPopover);
88
- console.log("isFirstHighlight", isFirstHighlight);
89
- console.log("hasNoPreviousPopover", hasNoPreviousPopover);
90
- console.log("isNextOrPrevDummyElement", isNextOrPrevDummyElement);
91
 
92
  hidePopover();
93
 
@@ -102,16 +95,19 @@ function transferHighlight(from: Element, to: Element, toStep: DriveStep) {
102
  }
103
 
104
  const elapsed = Date.now() - start;
 
 
 
 
 
 
 
105
 
106
  if (getConfig("animate") && elapsed < duration) {
107
  transitionStage(elapsed, duration, from, to);
108
  } else {
109
  trackActiveElement(to);
110
 
111
- if (hasDelayedPopover && toStep.popover) {
112
- renderPopover(to);
113
- }
114
-
115
  setState("transitionCallback", undefined);
116
  }
117
 
 
80
  const isNextOrPrevDummyElement = to.id === "driver-dummy-element" || from.id === "driver-dummy-element";
81
 
82
  const hasDelayedPopover = !isFirstHighlight && (hasNoPreviousPopover || isNextOrPrevDummyElement);
83
+ let isPopoverRendered = false;
 
 
 
 
 
 
 
84
 
85
  hidePopover();
86
 
 
95
  }
96
 
97
  const elapsed = Date.now() - start;
98
+ const timeRemaining = duration - elapsed;
99
+ const isHalfwayThrough = timeRemaining <= duration / 2;
100
+
101
+ if (toStep.popover && isHalfwayThrough && !isPopoverRendered && hasDelayedPopover) {
102
+ renderPopover(to);
103
+ isPopoverRendered = true;
104
+ }
105
 
106
  if (getConfig("animate") && elapsed < duration) {
107
  transitionStage(elapsed, duration, from, to);
108
  } else {
109
  trackActiveElement(to);
110
 
 
 
 
 
111
  setState("transitionCallback", undefined);
112
  }
113