Skip to content

Commit a7a4f11

Browse files
author
kirbIndustries
authored
Update index.js
1 parent 4b41e0f commit a7a4f11

1 file changed

Lines changed: 76 additions & 29 deletions

File tree

js/index.js

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13198,18 +13198,30 @@ function setupDrawerInteractions() {
1319813198
swipeOverlay.style.display = 'none';
1319913199
swipeOverlay.style.pointerEvents = 'none'; // Start with no interaction
1320013200
document.body.appendChild(swipeOverlay);
13201+
13202+
let isPendingDrag = false;
1320113203

13202-
function startDrag(xPosition, yPosition) {
13204+
function prepareDrag(xPosition, yPosition) {
1320313205
startX = xPosition;
1320413206
startY = yPosition;
1320513207
lastY = yPosition;
1320613208
currentX = xPosition;
1320713209
currentY = yPosition;
13210+
dragStartTime = Date.now();
13211+
isPendingDrag = true;
13212+
}
13213+
13214+
function startDrag(xPosition, yPosition) {
13215+
if (xPosition !== undefined) startX = xPosition;
13216+
if (yPosition !== undefined) startY = yPosition;
13217+
lastY = startY;
13218+
currentX = startX;
13219+
currentY = startY;
1320813220
dragStartIndex = -1; // Reset on new drag
1320913221
isDragging = true;
13222+
isPendingDrag = false;
1321013223
isDrawerInMotion = true;
13211-
dragStartTime = Date.now();
13212-
velocities = [];
13224+
velocities =[];
1321313225
appDrawer.style.transition = 'opacity 0.3s, filter 0.3s';
1321413226
document.querySelectorAll('.fullscreen-embed iframe').forEach(frame => {
1321513227
frame.style.pointerEvents = 'none';
@@ -13915,7 +13927,7 @@ function setupDrawerInteractions() {
1391513927
}
1391613928
}
1391713929

13918-
if (shouldStart) {
13930+
if (shouldStart) {
1391913931
// Set wallpaper start coordinates
1392013932
touchStartX = clientX;
1392113933
touchStartY = clientY;
@@ -13924,7 +13936,7 @@ function setupDrawerInteractions() {
1392413936

1392513937
// Ensure logic knows we are starting from open/closed state
1392613938
initialDrawerPosition = isDrawerOpen ? 0 : -100;
13927-
startDrag(clientX, clientY);
13939+
prepareDrag(clientX, clientY);
1392813940
}
1392913941
}, { passive: false });
1393013942

@@ -14003,7 +14015,7 @@ function setupDrawerInteractions() {
1400314015
touchEndY = clientY;
1400414016

1400514017
initialDrawerPosition = isDrawerOpen ? 0 : -100;
14006-
startDrag(clientX, clientY);
14018+
prepareDrag(clientX, clientY);
1400714019
}
1400814020
});
1400914021

@@ -14027,14 +14039,23 @@ function setupDrawerInteractions() {
1402714039
document.addEventListener('touchend', resetSplitGesture);
1402814040

1402914041
document.addEventListener('touchmove', (e) => {
14030-
if (oneButtonNavEnabled) return;
14031-
14032-
// --- New, more reliable split gesture detection ---
14033-
if (window.potentialSplitSide && !isDragging) {
14034-
const touch = e.touches[0];
14035-
const start = window.splitGestureStart;
14036-
const deltaX = touch.clientX - start.x;
14037-
const deltaY = touch.clientY - start.y;
14042+
if (handleSplitGestureMove(e.touches[0].clientX, e.touches[0].clientY)) {
14043+
e.preventDefault();
14044+
return;
14045+
}
14046+
14047+
if (isPendingDrag && !isDragging) {
14048+
const deltaX = Math.abs(e.touches[0].clientX - startX);
14049+
const deltaY = Math.abs(e.touches[0].clientY - startY);
14050+
if (deltaX > 10 || deltaY > 10) {
14051+
startDrag();
14052+
}
14053+
}
14054+
14055+
if (isDragging) {
14056+
const y = e.touches[0].clientY;
14057+
const isDrawerOpen = appDrawer.classList.contains('open');
14058+
const deltaY = startY - y; // Positive = Up, Negative = Down
1403814059

1403914060
// Check for a clear DIAGONAL-UP movement
1404014061
if (deltaY < -40 && Math.abs(deltaX) > 40) {
@@ -14121,7 +14142,7 @@ function setupDrawerInteractions() {
1412114142

1412214143
document.addEventListener('touchend', (e) => {
1412314144
if (oneButtonNavEnabled) return;
14124-
if (isDragging) {
14145+
if (isDragging || isPendingDrag) {
1412514146
let isTap = false;
1412614147
let tapX = 0, tapY = 0;
1412714148

@@ -14139,12 +14160,16 @@ function setupDrawerInteractions() {
1413914160
}
1414014161
}
1414114162

14142-
if (appSwitcherVisible) {
14143-
selectAndCloseAppSwitcher();
14144-
} else {
14145-
endDrag();
14163+
if (isDragging) {
14164+
if (appSwitcherVisible) {
14165+
selectAndCloseAppSwitcher();
14166+
} else {
14167+
endDrag();
14168+
}
14169+
isDragging = false;
1414614170
}
14147-
isDragging = false;
14171+
14172+
isPendingDrag = false;
1414814173

1414914174
// Forward the click if it was a fast tap on the handle
1415014175
if (isTap && dragSource === 'handle') {
@@ -14171,20 +14196,38 @@ function setupDrawerInteractions() {
1417114196
}
1417214197
});
1417314198

14174-
document.addEventListener('mousemove', (e) => {
14175-
if (oneButtonNavEnabled) return;
14199+
document.addEventListener('mousemove', (e) => {
14200+
// Check split gesture move
14201+
if (e.buttons === 1 && handleSplitGestureMove(e.clientX, e.clientY)) {
14202+
return;
14203+
}
14204+
14205+
if (isPendingDrag && !isDragging && e.buttons === 1) {
14206+
const deltaX = Math.abs(e.clientX - startX);
14207+
const deltaY = Math.abs(e.clientY - startY);
14208+
if (deltaX > 10 || deltaY > 10) {
14209+
startDrag();
14210+
}
14211+
}
14212+
1417614213
if (isDragging) {
14214+
// Update coordinates for wallpaper swipe calculation
14215+
touchEndX = e.clientX;
14216+
touchEndY = e.clientY;
1417714217
moveDrawer(e.clientX, e.clientY);
1417814218
}
1417914219
});
1418014220

1418114221
document.addEventListener('mouseup', (e) => {
1418214222
if (oneButtonNavEnabled) return;
14183-
// Prevent ghost duplicate clicks when using a touchscreen
14223+
// FIX: Prevent ghost duplicate clicks when using a touchscreen
1418414224
// (Browsers fire mouseup a few milliseconds after touchend)
1418514225
if (Date.now() - (window.lastTouchTime || 0) < 500) return;
1418614226

14187-
if (isDragging) {
14227+
if (isDragging || isPendingDrag) {
14228+
touchEndX = e.clientX;
14229+
touchEndY = e.clientY;
14230+
1418814231
let isTap = false;
1418914232
const deltaX = Math.abs(e.clientX - startX);
1419014233
const deltaY = Math.abs(e.clientY - startY);
@@ -14195,12 +14238,16 @@ function setupDrawerInteractions() {
1419514238
isTap = true;
1419614239
}
1419714240

14198-
if (appSwitcherVisible) {
14199-
selectAndCloseAppSwitcher();
14200-
} else {
14201-
endDrag();
14241+
if (isDragging) {
14242+
if (appSwitcherVisible) {
14243+
selectAndCloseAppSwitcher();
14244+
} else {
14245+
endDrag();
14246+
}
14247+
isDragging = false;
1420214248
}
14203-
isDragging = false;
14249+
14250+
isPendingDrag = false;
1420414251

1420514252
// Forward the click if it was a fast tap on the handle
1420614253
if (isTap && dragSource === 'handle') {

0 commit comments

Comments
 (0)