Skip to content

Commit 09b7077

Browse files
author
HimC29
committed
Fix not being able to resize window on mobile devices
1 parent 076c504 commit 09b7077

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

homeScreen/openApp.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export function openApp(app){
103103
}
104104
});
105105

106+
[minimizeBtn, maximizeBtn, closeBtn].forEach(btn => {
107+
btn.addEventListener("mousedown", e => e.stopPropagation());
108+
btn.addEventListener("touchstart", e => e.stopPropagation());
109+
});
110+
106111
// App iframe content
107112
const iframe = document.createElement("iframe");
108113
iframe.classList.add("iframe");
@@ -166,9 +171,6 @@ function draggableWindow(windowEl, handleEl){
166171
// Ignore clicks on title bar buttons
167172
if(e.target.closest(".titleBarBtn")) return;
168173

169-
// Only prevent default for drag actions, not button clicks
170-
if(e.touches) e.preventDefault();
171-
172174
isDragging = true;
173175

174176
// Calculate mouse offset inside window
@@ -195,7 +197,8 @@ function draggableWindow(windowEl, handleEl){
195197
});
196198
handleEl.addEventListener("touchstart", (e) => {
197199
detectTitleBarPress(e);
198-
}, { passive: false });
200+
}, { passive: true });
201+
199202

200203
function detectDrag(e){
201204
if(!isDragging) return;
@@ -293,7 +296,7 @@ function resizeableWindow(windowEl, handleEl){
293296
});
294297
handleEl.addEventListener("touchstart", (e) => {
295298
detectResizeElPress(e);
296-
}, { passive: false });
299+
});
297300

298301
function detectResizing(e){
299302
if(!isResizing) return;
@@ -324,9 +327,8 @@ function resizeableWindow(windowEl, handleEl){
324327
detectResizing(e);
325328
});
326329
document.addEventListener("touchmove", (e) => {
327-
if(isDragging) e.preventDefault();
328330
detectResizing(e);
329-
}, { passive: false });
331+
});
330332

331333
function detectResizeElRelease(){
332334
if(!isResizing) return;

0 commit comments

Comments
 (0)