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:
Mel Ludowise 2026-03-18 06:47:47 -07:00 • committed by GitHub
commit 83d82a1caa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 305 additions and 88 deletions

View file

@ -1,6 +1,7 @@
#graph {
width: 100%;
height: 100vh;
touch-action: none;
}
#popup {

View file

@ -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();