4e0481fd8d
Full screen button in the viewer's bottom bar opens a root full-screen route with the same bar and top bar; exit by the bar, Close, Escape or back. It renders the already fetched bytes, never the system browser. The external Open action is now labelled Open in browser. Native web views claim their gestures (vertical drags inline, every pointer in full screen) so the page swipe no longer starves them. On the web, full screen adds zoom buttons that scale the live sandboxed frame. Links: in-page anchors scroll, http(s)/mailto open outside, everything else is inert. Capture kit: --touch, swipe=, pinch=, tabs=; html=1 fixture artifact.
34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
// Touch input over one DevTools page session, for phone/tablet review:
|
|
// a touch-screen emulation switch, one-finger swipes and two-finger pinches.
|
|
// The events are trusted browser input, so they reach whatever the page puts
|
|
// under the finger (a Flutter canvas or an iframe platform view alike).
|
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
|
|
/** Emulates a touch screen (mobile metrics, 5 touch points). */
|
|
export async function enableTouch(send, { width, height }) {
|
|
await send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: true });
|
|
await send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });
|
|
}
|
|
|
|
/** One finger down at [at], moved by dx/dy in [steps] moves [gap] ms apart, lifted. */
|
|
export async function swipe(send, at, { dx = 0, dy = 0, steps = 12, gap = 16 } = {}) {
|
|
const touch = (type, x, y) => send('Input.dispatchTouchEvent', {
|
|
type, touchPoints: type === 'touchEnd' ? [] : [{ x, y, id: 1 }],
|
|
});
|
|
await touch('touchStart', at.x, at.y);
|
|
for (let i = 1; i <= steps; i++) {
|
|
await delay(gap);
|
|
await touch('touchMove', at.x + (dx * i) / steps, at.y + (dy * i) / steps);
|
|
}
|
|
await touch('touchEnd');
|
|
return { from: at, to: { x: at.x + dx, y: at.y + dy } };
|
|
}
|
|
|
|
/** Two fingers spread (scale > 1) or closed (< 1) around [at]. */
|
|
export async function pinch(send, at, scale) {
|
|
await send('Input.synthesizePinchGesture', {
|
|
x: at.x, y: at.y, scaleFactor: scale, relativeSpeed: 300, gestureSourceType: 'touch',
|
|
});
|
|
return at;
|
|
}
|