fix(examples): improve mobile support for map, pdf, and threejs examples (#555)
* Fix touch gesture conflicts in WebGL example apps on mobile * Format with prettier * fix(examples): improve mobile support for map, pdf, and threejs examples - map-server: fullscreen button respects safe area insets, hover/opacity pattern with always-visible on touch devices - pdf-server: fit-to-width scale for narrow viewports, responsive toolbar with compact controls on mobile, safe area in fullscreen toolbar via CSS custom properties - threejs-server: fullscreen button respects safe area and always visible on touch, ResizeObserver for responsive width, host containerDimensions for fullscreen height, no container padding in fullscreen, replace useHostStyles with inline style application to avoid overwriting onhostcontextchanged handler
This commit is contained in:
parent
704b6e0af9
commit
83d82a1caa
2 changed files with 305 additions and 88 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#graph {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
#popup {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,18 @@ const graph = new ForceGraph<NodeData, LinkData>(container)
|
|||
})
|
||||
.graphData(graphData);
|
||||
|
||||
// Prevent touch events from propagating to the parent scroll view.
|
||||
// force-graph uses pointer events, which don't suppress native scroll gesture
|
||||
// recognition on touch devices.
|
||||
const graphCanvas = container.querySelector("canvas");
|
||||
if (graphCanvas) {
|
||||
for (const eventName of ["touchstart", "touchmove"] as const) {
|
||||
graphCanvas.addEventListener(eventName, (e) => e.preventDefault(), {
|
||||
passive: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Handle window resize
|
||||
function handleResize() {
|
||||
const { width, height } = container.getBoundingClientRect();
|
||||
|
|
|
|||
Loading…
Reference in a new issue