Skip to content

Commit 796f29e

Browse files
committed
fix: element highlighting is very unpredictable
1 parent c672a10 commit 796f29e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,12 +3192,14 @@ function RemoteFunctions(config = {}) {
31923192

31933193
highlight.trackingElement = element; // save which node are we highlighting
31943194

3195-
if (transitionDuration) {
3196-
animateHighlight(transitionDuration);
3197-
}
3195+
if (doAnimation) {
3196+
if (transitionDuration) {
3197+
animateHighlight(transitionDuration);
3198+
}
31983199

3199-
if (animationDuration) {
3200-
animateHighlight(animationDuration);
3200+
if (animationDuration) {
3201+
animateHighlight(animationDuration);
3202+
}
32013203
}
32023204

32033205
// Don't highlight elements with 0 width & height
@@ -3894,10 +3896,11 @@ function RemoteFunctions(config = {}) {
38943896
element.style.backgroundColor = "rgba(0, 162, 255, 0.2)";
38953897
}
38963898

3897-
if (_hoverHighlight) {
3898-
_hoverHighlight.clear();
3899-
_hoverHighlight.add(element, true);
3899+
if (!_clickHighlight) {
3900+
_clickHighlight = new Highlight("#cfc");
39003901
}
3902+
_clickHighlight.clear();
3903+
_clickHighlight.add(element, true);
39013904

39023905
previouslyClickedElement = element;
39033906
}
@@ -4248,13 +4251,12 @@ function RemoteFunctions(config = {}) {
42484251
// Document scrolls can be updated immediately. Any other scrolls
42494252
// need to be updated on a timer to ensure the layout is correct.
42504253
if (e.target === window.document) {
4251-
redrawHighlights();
42524254
redrawRulerLines();
42534255
// need to dismiss the box if the elements are fixed, otherwise they drift at times
42544256
_dismissBoxesForFixedElements();
42554257
_repositionAIBox(); // and reposition the AI box
42564258
} else {
4257-
if (_localHighlight || _clickHighlight || _hoverHighlight) {
4259+
if (_localHighlight) {
42584260
window.setTimeout(redrawHighlights, 0);
42594261
}
42604262
if (_currentRulerLines) {

0 commit comments

Comments
 (0)