mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
fixing issues in auto arrange while moving items
This commit is contained in:
parent
c63e546a9c
commit
ed663c0824
@ -188,7 +188,7 @@ function UIItem(options){
|
||||
}
|
||||
|
||||
// position
|
||||
if(!is_auto_arrange_enabled && options.position && $(el_item).attr('data-path') !== trash_path){
|
||||
if(!is_auto_arrange_enabled && options.position && $(el_item).closest('.item-container').attr('data-path') === window.desktop_path){
|
||||
el_item.style.position = 'absolute';
|
||||
el_item.style.left = options.position.left + 'px';
|
||||
el_item.style.top = options.position.top + 'px';
|
||||
@ -342,7 +342,9 @@ function UIItem(options){
|
||||
}
|
||||
},
|
||||
stop: function(event, ui){
|
||||
if(!is_auto_arrange_enabled && $(el_item).attr('data-path') !== trash_path){
|
||||
// Allow rearranging only if item is on desktop, not trash container, auto arrange is disabled and item is not dropped into another item
|
||||
if($(el_item).closest('.item-container').attr('data-path') === window.desktop_path &&
|
||||
!is_auto_arrange_enabled && $(el_item).attr('data-path') !== trash_path && !ui.helper.data('dropped')){
|
||||
el_item.style.position = 'absolute';
|
||||
el_item.style.left = ui.position.left + 'px';
|
||||
el_item.style.top = ui.position.top + 'px';
|
||||
@ -378,6 +380,9 @@ function UIItem(options){
|
||||
if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
|
||||
return;
|
||||
|
||||
// Adding a flag to know whether item is rearraged or dropped
|
||||
ui.helper.data('dropped', true);
|
||||
|
||||
const items_to_move = []
|
||||
|
||||
// First item
|
||||
@ -452,6 +457,10 @@ function UIItem(options){
|
||||
}
|
||||
// Otherwise, move items
|
||||
else if(options.is_dir){
|
||||
if($(el_item).closest('.item-container').attr('data-path') === window.desktop_path){
|
||||
delete desktop_item_positions[$(el_item).attr('data-uid')];
|
||||
save_desktop_item_positions()
|
||||
}
|
||||
move_items(items_to_move, $(el_item).attr('data-shortcut_to_path') !== '' ? $(el_item).attr('data-shortcut_to_path') : $(el_item).attr('data-path'));
|
||||
}
|
||||
}
|
||||
|
@ -176,4 +176,5 @@ window.feature_flags = {
|
||||
}
|
||||
|
||||
window.is_auto_arrange_enabled = true;
|
||||
window.desktop_item_positions = {};
|
||||
window.desktop_item_positions = {};
|
||||
window.reset_item_positions = true; // The variable decides if the item positions should be reset when the user enabled auto arrange
|
@ -3718,6 +3718,9 @@ window.clear_desktop_item_positions = async(el_desktop)=>{
|
||||
$(el_item).css('left', '');
|
||||
$(el_item).css('top', '');
|
||||
});
|
||||
if(reset_item_positions){
|
||||
delete_desktop_item_positions()
|
||||
}
|
||||
}
|
||||
|
||||
window.set_desktop_item_positions = async(el_desktop)=>{
|
||||
@ -3735,3 +3738,8 @@ window.set_desktop_item_positions = async(el_desktop)=>{
|
||||
window.save_desktop_item_positions = ()=>{
|
||||
puter.kv.set('desktop_item_positions', desktop_item_positions);
|
||||
}
|
||||
|
||||
window.delete_desktop_item_positions = ()=>{
|
||||
desktop_item_positions = {}
|
||||
puter.kv.del('desktop_item_positions');
|
||||
}
|
Loading…
Reference in New Issue
Block a user