Skip to content

Commit 4a1cce8

Browse files
committed
fix: quick view comes up too freqeuntly on hover. now we only show when mouse doesnt move
1 parent c74ac2c commit 4a1cce8

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

src/features/QuickViewManager.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ define(function (require, exports, module) {
245245
const CMD_ENABLE_QUICK_VIEW = "view.enableQuickView",
246246
QUICK_VIEW_EDITOR_MARKER = 'quickViewMark',
247247
// Time (ms) mouse must remain over a provider's matched text before popover appears
248-
HOVER_DELAY = 500,
248+
HOVER_DELAY = 350,
249249
// Pointer height, used to shift popover above pointer (plus a little bit of space)
250250
POINTER_HEIGHT = 10,
251251
POPOVER_HORZ_MARGIN = 5; // Horizontal margin
@@ -300,7 +300,6 @@ define(function (require, exports, module) {
300300
EditorManager.getActiveEditor().focus();
301301
}
302302
}
303-
showPreviewQueued = false;
304303
mouseInPreviewContainer = false;
305304
unlockQuickView();
306305
window.clearTimeout(popoverState.hoverTimer);
@@ -546,8 +545,6 @@ define(function (require, exports, module) {
546545
return false;
547546
}
548547

549-
let showPreviewQueued = false;
550-
551548
function processMouseMove() {
552549
animationRequest = null;
553550

@@ -579,24 +576,21 @@ define(function (require, exports, module) {
579576
}
580577
}
581578

582-
if(!showPreviewQueued){
583-
// Initialize popoverState
584-
showPreviewQueued = true;
585-
popoverState = popoverState || {};
586-
587-
// Set timer to scan and show. This will get cancelled (in hidePreview())
588-
// if mouse movement rendered this popover inapplicable before timer fires.
589-
// When showing "immediately", still use setTimeout() to make this async
590-
// so we return from this mousemove event handler ASAP.
591-
popoverState.hoverTimer = window.setTimeout(function () {
592-
showPreviewQueued = false;
593-
if(!mouseInPreviewContainer && !quickViewLocked){
594-
hidePreview();
595-
popoverState = {};
596-
showPreview(editor);
597-
}
598-
}, HOVER_DELAY);
599-
}
579+
popoverState = popoverState || {};
580+
581+
// Set timer to scan and show. This will get cancelled (in hidePreview())
582+
// if mouse movement rendered this popover inapplicable before timer fires.
583+
// When showing "immediately", still use setTimeout() to make this async
584+
// so we return from this mousemove event handler ASAP.
585+
clearTimeout(popoverState.hoverTimer);
586+
popoverState.hoverTimer = window.setTimeout(function () {
587+
if(!mouseInPreviewContainer && !quickViewLocked){
588+
console.error("showing");
589+
hidePreview();
590+
popoverState = {};
591+
showPreview(editor);
592+
}
593+
}, HOVER_DELAY);
600594
}
601595

602596
function handleMouseMove(event) {

0 commit comments

Comments
 (0)