MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / handleViewportWheel

Function handleViewportWheel

packages/client/src/app/AppShell.tsx:2424–2468  ·  view source on GitHub ↗
(event: React.WheelEvent<HTMLElement>)

Source from the content-addressed store, hash-verified

2422 });
2423
2424 function handleViewportWheel(event: React.WheelEvent<HTMLElement>) {
2425 if (!selectedSimulator) {
2426 return;
2427 }
2428
2429 event.preventDefault();
2430 event.stopPropagation();
2431 const deltaScale =
2432 event.deltaMode === WheelEvent.DOM_DELTA_LINE
2433 ? 16
2434 : event.deltaMode === WheelEvent.DOM_DELTA_PAGE
2435 ? 240
2436 : 1;
2437 const deltaX = event.deltaX * deltaScale;
2438 const deltaY = event.deltaY * deltaScale;
2439
2440 if (event.ctrlKey || event.metaKey) {
2441 const nextScale = effectiveZoom * Math.exp(-deltaY * 0.002);
2442 applyZoomAtClientPoint(nextScale, event.clientX, event.clientY);
2443 return;
2444 }
2445
2446 if (chromeHasCrown && selectedSimulator.isBooted) {
2447 sendCrownRotation(deltaY);
2448 return;
2449 }
2450
2451 setPan(
2452 (currentPan) =>
2453 nextViewportWheelPanState({
2454 canvasSize,
2455 chromeProfile: viewportChromeProfile,
2456 deltaX,
2457 deltaY,
2458 deviceNaturalSize: effectiveDeviceNaturalSize,
2459 effectiveZoom,
2460 fitScale,
2461 pan: currentPan,
2462 reservedBottomInset: zoomDockReservedHeight,
2463 rotationQuarterTurns: viewportRotationQuarterTurns,
2464 viewMode,
2465 zoom,
2466 }).pan,
2467 );
2468 }
2469
2470 function showTouchIndicator(phase: TouchPhase, coords: Point) {
2471 showTouchIndicators(phase, [coords]);

Callers

nothing calls this directly

Calls 3

applyZoomAtClientPointFunction · 0.85
sendCrownRotationFunction · 0.85

Tested by

no test coverage detected