mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(core): do not clip center-peek controls to make it appear more quickly (#7572)
fix AF-1084 
This commit is contained in:
@@ -42,6 +42,12 @@ export const modalContentContainer = style({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
export const modalContentClip = style({
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
borderRadius: 'inherit',
|
||||||
|
overflow: 'hidden',
|
||||||
|
});
|
||||||
|
|
||||||
export const dialog = style({
|
export const dialog = style({
|
||||||
backgroundColor: cssVar('backgroundOverlayPanelColor'),
|
backgroundColor: cssVar('backgroundOverlayPanelColor'),
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
const toRect = to.getBoundingClientRect();
|
const toRect = to.getBoundingClientRect();
|
||||||
|
|
||||||
targets.style.position = 'fixed';
|
targets.style.position = 'fixed';
|
||||||
targets.style.overflow = 'hidden';
|
|
||||||
targets.style.opacity = '1';
|
targets.style.opacity = '1';
|
||||||
lockSizeEl.style.width = zoomIn
|
lockSizeEl.style.width = zoomIn
|
||||||
? `${toRect.width}px`
|
? `${toRect.width}px`
|
||||||
@@ -179,7 +178,6 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
top: '',
|
top: '',
|
||||||
width: '',
|
width: '',
|
||||||
height: '',
|
height: '',
|
||||||
overflow: '',
|
|
||||||
});
|
});
|
||||||
Object.assign(lockSizeEl.style, {
|
Object.assign(lockSizeEl.style, {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -200,6 +198,18 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
},
|
},
|
||||||
[target]
|
[target]
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* ### Animation timeline:
|
||||||
|
* ```plain
|
||||||
|
* 150ms
|
||||||
|
* ⎮ - - - - ⎮
|
||||||
|
* dialog: +--------400ms--------+
|
||||||
|
* controls: +-------230ms-------+
|
||||||
|
* ⎮ - - - - - ⎮
|
||||||
|
* controls delay =
|
||||||
|
* 400 - 230 + 150
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
const animateZoomIn = useCallback(() => {
|
const animateZoomIn = useCallback(() => {
|
||||||
setAnimeState('animating');
|
setAnimeState('animating');
|
||||||
setVtOpen(true);
|
setVtOpen(true);
|
||||||
@@ -214,10 +224,13 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
opacity: [0, 1],
|
opacity: [0, 1],
|
||||||
duration: 100,
|
duration: 100,
|
||||||
},
|
},
|
||||||
})
|
}).catch(console.error);
|
||||||
.then(() => animateControls(true))
|
|
||||||
.catch(console.error);
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
setTimeout(
|
||||||
|
() => animateControls(true),
|
||||||
|
// controls delay: to make sure the time interval for animations of dialog and controls is 150ms.
|
||||||
|
400 - 230 + 150
|
||||||
|
);
|
||||||
}, [animateControls, zoomAnimate]);
|
}, [animateControls, zoomAnimate]);
|
||||||
const animateZoomOut = useCallback(() => {
|
const animateZoomOut = useCallback(() => {
|
||||||
setAnimeState('animating');
|
setAnimeState('animating');
|
||||||
@@ -308,20 +321,27 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
ref={contentClipRef}
|
ref={contentClipRef}
|
||||||
className={styles.modalContentContainer}
|
className={styles.modalContentContainer}
|
||||||
>
|
>
|
||||||
<Dialog.Content
|
<div className={styles.modalContentClip}>
|
||||||
{...contentOptions}
|
<Dialog.Content
|
||||||
className={clsx({
|
{...contentOptions}
|
||||||
[styles.modalContent]: true,
|
className={clsx({
|
||||||
[styles.dialog]: dialogFrame,
|
[styles.modalContent]: true,
|
||||||
})}
|
[styles.dialog]: dialogFrame,
|
||||||
>
|
})}
|
||||||
<Dialog.Title style={{ display: 'none' }} />
|
>
|
||||||
<div style={{ height: '100%' }} ref={contentRef}>
|
<Dialog.Title style={{ display: 'none' }} />
|
||||||
{children}
|
<div style={{ height: '100%' }} ref={contentRef}>
|
||||||
</div>
|
{children}
|
||||||
</Dialog.Content>
|
</div>
|
||||||
|
</Dialog.Content>
|
||||||
|
</div>
|
||||||
{controls ? (
|
{controls ? (
|
||||||
<div ref={controlsRef} className={styles.modalControls}>
|
<div
|
||||||
|
// initially hide the controls to prevent flickering for zoom animation
|
||||||
|
style={{ opacity: animation === 'zoom' ? 0 : undefined }}
|
||||||
|
ref={controlsRef}
|
||||||
|
className={styles.modalControls}
|
||||||
|
>
|
||||||
{controls}
|
{controls}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user