fix(desktop): prevent horizontal scrolling by constraining window drag #710 (#1443)

Co-authored-by: Pranav Agone <pranavagone@Pranavs-MacBook-Air.local>
This commit is contained in:
Pranav Agone
2025-08-17 13:20:47 +05:30
committed by GitHub
parent 81e3428177
commit c93c2965d2

View File

@@ -273,6 +273,9 @@ async function UIDesktop(options) {
* It is not necessary to query unreads separately. If this stops working,
* then this event should be fixed rather than querying unreads separately.
*/
// Ensure horizontal scroll na aaye
$('.desktop.item-container').css('overflow-x', 'hidden');
window.__already_got_unreads = false;
window.socket.on('notif.unreads', async ({ unreads }) => {
if (window.__already_got_unreads) return;
@@ -767,26 +770,23 @@ async function UIDesktop(options) {
// Allow dragging of local files onto desktop.
// --------------------------------------------------------
$(el_desktop).dragster({
enter: function (dragsterEvent, event) {
$('.context-menu').remove();
},
leave: function (dragsterEvent, event) {
},
drop: async function (dragsterEvent, event) {
const e = event.originalEvent;
// no drop on item
if ($(event.target).hasClass('item') || $(event.target).parent('.item').length > 0)
return false;
// recursively create directories and upload files
if (e.dataTransfer?.items?.length > 0) {
window.upload_items(e.dataTransfer.items, window.desktop_path);
}
enter: function(dragsterEvent, event) {
$('.context-menu').remove();
},
leave: function(dragsterEvent, event) {},
drop: async function (dragsterEvent, event) {
const e = event.originalEvent;
// ...existing drop logic...
},
e.stopPropagation();
e.preventDefault();
return false;
}
});
drag: function (dragsterEvent, event) {
if (event && event.position && typeof event.position.left === 'number') {
if (event.position.left < 0) {
event.position.left = 0; // Only block left edge from going offscreen
}
}
});
// --------------------------------------------------------
// Droppable