Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): Browser panel now slides with the panel animation #28669

ClosedByntham(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/28669/headopened View on GitHub

Showing 5 changed files with 83 additions and 37 deletions (loading 2).

x
0 of 5 viewed, 5 left
50 additions and 26 deletionsapps/web/src/browser/BrowserSurfaceSlot.tsxModified
View file
@@ -27,41 +27,45 @@
// The lease lives as long as this element for one tab, so the ref callback owns it.
const attachSurface = (element: HTMLDivElement) => {
let lease = acquireBrowserSurface(tabId, fitSourceContent);
+ // An inline panel animates its clip box while the slot keeps its final size and position.
+ const panel = element.closest<HTMLElement>("[data-preview-panel-clip]");
+ let wasVisible = presentationRef.current.visible;
+ let closing = false;
const update = () => {
- const rect = element.getBoundingClientRect();
+ const bounds = element.getBoundingClientRect();
const presentation = presentationRef.current;
- const presented = lease.present(
- {
- x: Math.round(rect.x),
- y: Math.round(rect.y),
- width: Math.max(1, Math.round(rect.width)),
- height: Math.max(1, Math.round(rect.height)),
- },
- presentation.visible && rect.width > 0 && rect.height > 0,
- presentation.cornerRadius,
- presentation.zIndex,
- );
- if (presentation.visible && !presented) {
+ if (presentation.visible !== wasVisible) {
+ wasVisible = presentation.visible;
+ // A close hides the slot in the same commit that marks the panel closed; stay on
+ // screen while it slides away, like the DOM surfaces beside it.
+ closing = !presentation.visible && panel?.dataset.previewPanelClip === "closed";