mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-13 09:21:04 +00:00
Fix/explorer cursor grab on click (#2176)
* Fix sidebar cursor grabbing on click * Final commit
This commit is contained in:
1 parent
754e820403
commit
e20daf276b
1 file changed
+32
-5
@@ -2044,10 +2044,10 @@ async function UIWindow (options) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! activeZone ) {
|
||||
hideSnapPlaceholder();
|
||||
if ( ! activeZone ) {
|
||||
hideSnapPlaceholder();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
stop: function () {
|
||||
window.a_window_is_being_dragged = false;
|
||||
@@ -2781,12 +2781,39 @@ async function UIWindow (options) {
|
||||
// Make the sortable operation more responsive
|
||||
$sidebar.on('mousedown', '.window-sidebar-item', function (e) {
|
||||
if ( ! $(this).hasClass('window-sidebar-title') ) {
|
||||
$(this).addClass('grabbing');
|
||||
const $item = $(this);
|
||||
|
||||
// Clear any existing timeout for this item
|
||||
const existingTimeout = $item.data('grabTimeout');
|
||||
if (existingTimeout) {
|
||||
clearTimeout(existingTimeout);
|
||||
}
|
||||
|
||||
const grabTimeout = setTimeout(() => {
|
||||
$item.addClass('grabbing');
|
||||
}, 300);
|
||||
// Store timeout reference on the element
|
||||
$item.data('grabTimeout', grabTimeout);
|
||||
|
||||
$(document).one('mouseup', function () {
|
||||
const timeout = $item.data('grabTimeout');
|
||||
if(timeout){
|
||||
clearTimeout(timeout);
|
||||
$item.removeData('grabTimeout');
|
||||
}
|
||||
$item.removeClass('grabbing');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$sidebar.on('mouseup mouseleave', '.window-sidebar-item', function () {
|
||||
$(this).removeClass('grabbing');
|
||||
const $item = $(this);
|
||||
const timeout = $item.data('grabTimeout');
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
$item.removeData('grabTimeout');
|
||||
}
|
||||
$item.removeClass('grabbing');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user