fix(core): peek view animation use zoom when possible (#8793)

fix AF-1667
This commit is contained in:
pengx17
2024-11-13 02:40:01 +00:00
parent b5fa8472d9
commit 01d1631fe8
2 changed files with 18 additions and 4 deletions

View File

@@ -258,10 +258,7 @@ export class PeekViewEntity extends Entity {
this._active$.next({ target, info: resolvedInfo });
this._show$.next({
value: true,
animation:
resolvedInfo.type === 'doc' || resolvedInfo.type === 'ai-chat-block'
? 'zoom'
: 'fade',
animation: target.element ? 'zoom' : 'fade',
});
if (abortSignal) {

View File

@@ -128,6 +128,23 @@ export const PeekViewModalContainer = forwardRef<
const targets = contentClip;
const lockSizeEl = content;
// if target has no bounding client rect, find its parent that has bounding client rect
let iteration = 0;
while (
target &&
!target.getBoundingClientRect().width &&
iteration < 10
) {
// eslint-disable-next-line react-hooks/exhaustive-deps
target = target.parentElement || undefined;
iteration++;
}
if (!target) {
resolve();
return;
}
const from = zoomIn ? target : contentClip;
const to = zoomIn ? contentClip : target;