Repository navigation
fix(desktop): trackpad pinch magnifies the window #27937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import type { ScopedThreadRef, SnapShotSource } from "@t3tools/contracts"; | |
|
|
||
| import type { DraftId } from "../composerDraftStore"; | ||
| import { getDesktopSnapShotBridge } from "./desktopSnapShot"; | ||
| import { toVisualViewportRect } from "./visualViewport"; | ||
|
|
||
| type SnapShotTarget = DraftId | ScopedThreadRef; | ||
|
|
||
|
|
@@ -117,12 +118,7 @@ export function setSnapShotAnimationDestination( | |
| const request = bridge | ||
| .setSnapShotAnimationDestination({ | ||
| id, | ||
| viewportFrame: { | ||
| x: frame.x, | ||
| y: frame.y, | ||
| width: frame.width, | ||
| height: frame.height, | ||
| }, | ||
| viewportFrame: toVisualViewportRect(frame), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| backgroundColor: style.backgroundColor, | ||
| borderColor: style.borderTopColor, | ||
| borderWidth: Number.isFinite(borderWidth) ? borderWidth : 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| interface Point { | ||
| readonly x: number; | ||
| readonly y: number; | ||
| } | ||
|
|
||
| interface Rect extends Point { | ||
| readonly width: number; | ||
| readonly height: number; | ||
| } | ||
|
|
||
| // clientX/Y and getBoundingClientRect are layout-viewport coordinates; native window coordinates | ||
| // follow what is drawn, which moves while the desktop window is pinch-magnified and panned. | ||
| export function toVisualViewportPoint(point: Point): Point { | ||
| const viewport = window.visualViewport; | ||
| if (!viewport) return point; | ||
| return { | ||
| x: (point.x - viewport.offsetLeft) * viewport.scale, | ||
| y: (point.y - viewport.offsetTop) * viewport.scale, | ||
| }; | ||
| } | ||
|
|
||
| export function toVisualViewportRect(rect: Rect): Rect { | ||
| const scale = window.visualViewport?.scale ?? 1; | ||
| return { | ||
| ...toVisualViewportPoint(rect), | ||
| width: rect.width * scale, | ||
| height: rect.height * scale, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low
lib/snapShotAnimation.ts:121During pinch zoom,
viewportFrameis scaled into visual-viewport coordinates butborderWidthandcornerRadiusremain unscaled CSS pixels, so the arrival card’s border and corners do not match the target (at 2×, an 8px radius stays 8px instead of 16px). Scale both appearance dimensions by the same pinch factor used bytoVisualViewportRect.🤖 Copy this AI Prompt to have your agent fix this: