mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-05 00:50:41 +00:00
fix: debounce toolbar display after dragging a window
This commit is contained in:
@@ -1547,10 +1547,30 @@ async function UIDesktop(options) {
|
||||
}, hideDelay);
|
||||
};
|
||||
|
||||
// debounce timer to prevent toolbar showing immediately after drag ends
|
||||
window.dragReleaseDebounceTimer = null;
|
||||
const DRAG_RELEASE_DEBOUNCE_MS = 300;
|
||||
|
||||
// track when drag operations end to enable debounce
|
||||
$(document).on('dragend', function() {
|
||||
window.dragReleaseDebounceTimer = setTimeout(() => {
|
||||
window.dragReleaseDebounceTimer = null;
|
||||
}, DRAG_RELEASE_DEBOUNCE_MS);
|
||||
});
|
||||
|
||||
// also debounce when mouseup occurs while in drag state
|
||||
$(document).on('mouseup', function() {
|
||||
if (window.a_window_is_being_dragged || window.an_item_is_being_dragged) {
|
||||
window.dragReleaseDebounceTimer = setTimeout(() => {
|
||||
window.dragReleaseDebounceTimer = null;
|
||||
}, DRAG_RELEASE_DEBOUNCE_MS);
|
||||
}
|
||||
});
|
||||
|
||||
// hovering over a hidden toolbar will show it
|
||||
$(document).on('mouseenter', '.toolbar-hidden', function () {
|
||||
// if a window is being dragged, don't show the toolbar
|
||||
if(window.a_window_is_being_dragged)
|
||||
// if a window is being dragged or currently in drag release debounce period, don't show the toolbar
|
||||
if(window.a_window_is_being_dragged || window.dragReleaseDebounceTimer !== null)
|
||||
return;
|
||||
|
||||
// if selectable is active , don't show the toolbar
|
||||
|
||||
Reference in New Issue
Block a user