Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

pengx1701d1631fe8f7
diff --git a/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts b/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
index fb05b24c3f..bc2537b95e 100644
--- a/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
+++ b/packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
@@ -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) {
diff --git a/packages/frontend/core/src/modules/peek-view/view/modal-container.tsx b/packages/frontend/core/src/modules/peek-view/view/modal-container.tsx
index 89eea67b38..0ae0fc1b6b 100644
--- a/packages/frontend/core/src/modules/peek-view/view/modal-container.tsx
+++ b/packages/frontend/core/src/modules/peek-view/view/modal-container.tsx
@@ -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;