Open ciampo opened 1 month ago
I had a timeboxed attempt at this, and this doesn't look like a simple task. Here are some initial observations:
isBlockInsertionPointVisible
selector from the core/block-editor
data store. Since the whole component is unmounted when not visible, its code stops running and therefore it can't handle an exit animation.getBlockInsertionPoint
selector defaults to the last block (as also written in the docs), meaning that we'd need to ignore this information while animating out, otherwise, the in-between inserter would disappear from its current location, and animate in the new insertion point.With the above observations in mind, I thought of a potential approach:
I had a timeboxed attempt at this, and this doesn't look like a simple task. Here are some initial observations:
isBlockInsertionPointVisible
selector from the core/block-editor
data store. Since the whole component is unmounted when not visible, its code stops running and therefore it can't handle an exit animation.getBlockInsertionPoint
selector defaults to the last block (as also written in the docs), meaning that we'd need to ignore this information while animating out, otherwise, the in-between inserter would disappear from its current location, and animate in the new insertion point.With the above observations in mind, I thought of a potential approach:
cc @WordPress/gutenberg-components @mtias
The in-between block inserter currently appears in the block editor canvas with an enter animation:
https://github.com/user-attachments/assets/2a2afcb3-080c-4990-adb4-1ece34190621
We should add an exit animation too, for an increased sense of UI polish.
Click to show animation specs
``` IN ANIMATION: (0.58, 0.00, 0.06, 1.00) Total duration: 430ms STROKE (SCALE) Length: 40% → 100% Width: 2px → 8px Duration: 400ms STROKE (OPACITY) - Opacity: 0 → 1 Duration: 50ms Delay: 65ms -- 'PLUS' BUTTON (SCALE) - Scale: 0.6 → 1 Duration: 400ms Delay: 30ms 'PLUS' BUTTON (OPACITY) - Opacity: 0 → 1 Duration: 50ms Delay: 130ms --- OUT ANIMATION: (0.96, 0.00, 0.32, 1.00) Total duration: 330ms STROKE (SCALE) Length: 100% → 40% Width: 8px → 2px Duration: 280ms Delay: 50ms STROKE (OPACITY) - Opacity: 1 → 0 Duration: 50ms Delay: 220ms -- 'PLUS' BUTTON (SCALE) - Scale: 1 → 0.4 Duration: 280ms 'PLUS' BUTTON (OPACITY) - Opacity: 1 → 0 Duration: 50ms Delay: 180ms ```