openguessr-ui 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Popup.svelte +16 -6
- package/package.json +1 -1
package/components/Popup.svelte
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
|
|
65
65
|
// Drawer state
|
|
66
66
|
let dragStartY = $state();
|
|
67
|
+
let dragStartX;
|
|
67
68
|
let dragStartVerticalOffset;
|
|
68
69
|
let isDragging = $state(false);
|
|
69
70
|
let drawerVerticalOffset = $state(0);
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
cancelAnimationFrame(openAnimationFrame);
|
|
95
96
|
dragStartVerticalOffset = drawerVerticalOffset;
|
|
96
97
|
dragStartY = event.touches[0].clientY;
|
|
98
|
+
dragStartX = event.touches[0].clientX;
|
|
97
99
|
velocitySamples = [{ y: dragStartY, time: performance.now() }];
|
|
98
100
|
};
|
|
99
101
|
|
|
@@ -102,11 +104,19 @@
|
|
|
102
104
|
|
|
103
105
|
const eventY = event.touches[0].clientY;
|
|
104
106
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
// On the first move, decide whether the gesture drags the drawer or scrolls the content
|
|
108
|
+
if (!isDragging) {
|
|
109
|
+
// Horizontal movements belong to the content, e.g. horizontally scrolling elements
|
|
110
|
+
const isScrollingHorizontally = Math.abs(event.touches[0].clientX - dragStartX) > Math.abs(eventY - dragStartY); // Check if more horizontal movement than vertical
|
|
111
|
+
|
|
112
|
+
// Dragging finger upwards while the touched element (or an ancestor up to the content) can still scroll down
|
|
113
|
+
// Mainly relevant for the slow stretch animation when the drwaer is dragged upwards (which shouldn't show when content is scrolled down)
|
|
114
|
+
const isScrollingDown = eventY <= dragStartY && canScrollDown(event.target, contentEl);
|
|
115
|
+
|
|
116
|
+
if (isScrollingHorizontally || isScrollingDown) {
|
|
117
|
+
dragStartY = null;
|
|
118
|
+
return animateDrawerOpen(); // Touch could've stopped the drawer during open, since it's a content scroll not a drag, resume
|
|
119
|
+
}
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
event.preventDefault(); // Prevent page scroll
|
|
@@ -340,7 +350,7 @@
|
|
|
340
350
|
width: 100%;
|
|
341
351
|
/* Max height is also shorter by the negative --layout-spacer margin bottom */
|
|
342
352
|
max-height: calc(100dvh - env(safe-area-inset-top));
|
|
343
|
-
padding-bottom: calc(var(--window-padding)
|
|
353
|
+
padding-bottom: calc(max(var(--window-padding), env(safe-area-inset-bottom)) + var(--layout-spacer));
|
|
344
354
|
margin-bottom: calc(-1 * var(--layout-spacer));
|
|
345
355
|
border-bottom-left-radius: 0;
|
|
346
356
|
border-bottom-right-radius: 0;
|