fix: polish post transition details
This commit is contained in:
1 parent
cb89f1190c
commit
7cc1f0e228
3 files changed
+67
-10
No files matched your search
+45
-4
@@ -960,6 +960,25 @@ html.home-view-transition.returning-home #pagePost .post-detail-signature {
|
||||
view-transition-name: post-detail-signature;
|
||||
}
|
||||
|
||||
html.post-view-transition #pagePost .post-reply-count {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
html.post-transition-settled #pagePost .post-reply-count {
|
||||
animation: postReplyCountReveal 0.2s ease-out both;
|
||||
}
|
||||
|
||||
@keyframes postReplyCountReveal {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(4px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
html.post-view-transition .post-card .post-title,
|
||||
html.home-view-transition.returning-home .post-card .post-title {
|
||||
display: block;
|
||||
@@ -972,9 +991,22 @@ html.home-view-transition::view-transition {
|
||||
background: linear-gradient(145deg, var(--bg-start) 0%, var(--bg-end) 100%);
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-group(post-expand) {
|
||||
html.post-view-transition::view-transition-group(post-expand),
|
||||
html.home-view-transition.returning-home::view-transition-group(post-expand) {
|
||||
animation-duration: 0.96s;
|
||||
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
animation-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
|
||||
border-radius: var(--radius);
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-image-pair(post-expand),
|
||||
html.home-view-transition.returning-home::view-transition-image-pair(post-expand),
|
||||
html.post-view-transition::view-transition-old(post-expand),
|
||||
html.post-view-transition::view-transition-new(post-expand),
|
||||
html.home-view-transition.returning-home::view-transition-old(post-expand),
|
||||
html.home-view-transition.returning-home::view-transition-new(post-expand) {
|
||||
border-radius: var(--radius);
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-group(post-sidebar) {
|
||||
@@ -1029,11 +1061,20 @@ html.post-view-transition::view-transition-new(root) {
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-old(post-expand) {
|
||||
animation: postCardFadeOut 0.2s 0.5s ease-out both;
|
||||
animation: none;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
mix-blend-mode: normal;
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-new(post-expand) {
|
||||
animation: postCardReveal 0.22s 0.56s ease-out both;
|
||||
animation: none;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 1;
|
||||
object-fit: fill;
|
||||
mix-blend-mode: normal;
|
||||
}
|
||||
|
||||
html.post-view-transition::view-transition-old(post-heading) {
|
||||
|
||||
@@ -52,7 +52,13 @@ function waitForPostImages(container) {
|
||||
});
|
||||
}
|
||||
|
||||
function stageSharedGeometry(transition, { name, duration, moveOffset }) {
|
||||
function stageSharedGeometry(transition, {
|
||||
name,
|
||||
duration,
|
||||
moveOffset,
|
||||
moveEasing = 'cubic-bezier(0.16, 1, 0.3, 1)',
|
||||
resizeEasing = 'cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
}) {
|
||||
transition.ready.then(() => {
|
||||
const groupAnimation = document.getAnimations().find(
|
||||
(animation) => animation.effect?.pseudoElement === `::view-transition-group(${name})`
|
||||
@@ -68,14 +74,14 @@ function stageSharedGeometry(transition, { name, duration, moveOffset }) {
|
||||
width: start.width,
|
||||
height: start.height,
|
||||
transform: start.transform,
|
||||
easing: 'cubic-bezier(0.16, 1, 0.3, 1)',
|
||||
easing: moveEasing,
|
||||
},
|
||||
{
|
||||
offset: moveOffset,
|
||||
width: end.width,
|
||||
height: start.height,
|
||||
transform: end.transform,
|
||||
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
easing: resizeEasing,
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
@@ -309,6 +315,7 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.documentElement.classList.remove('post-transition-settled');
|
||||
sourceElement.style.viewTransitionName = 'post-expand';
|
||||
const sourceParts = namePostTransitionParts(sourceElement);
|
||||
document.documentElement.classList.add('post-view-transition');
|
||||
@@ -316,7 +323,13 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
flushSync(commitNavigation);
|
||||
await waitForPostImages(document.querySelector('#pagePost .post-detail-card'));
|
||||
});
|
||||
stageSharedGeometry(transition, { name: 'post-expand', duration: 960, moveOffset: 0.62 });
|
||||
stageSharedGeometry(transition, {
|
||||
name: 'post-expand',
|
||||
duration: 960,
|
||||
moveOffset: 0.62,
|
||||
moveEasing: 'cubic-bezier(0.42, 0, 0.58, 1)',
|
||||
resizeEasing: 'cubic-bezier(0.42, 0, 0.58, 1)',
|
||||
});
|
||||
stageSharedGeometry(transition, { name: 'post-body', duration: 960, moveOffset: 0.62 });
|
||||
const clearSourceNames = () => {
|
||||
sourceElement.style.viewTransitionName = '';
|
||||
@@ -324,7 +337,10 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
};
|
||||
transition.ready.then(clearSourceNames, clearSourceNames);
|
||||
transition.finished.finally(() => {
|
||||
document.documentElement.classList.remove('post-view-transition');
|
||||
const root = document.documentElement;
|
||||
root.classList.remove('post-view-transition');
|
||||
root.classList.add('post-transition-settled');
|
||||
window.setTimeout(() => root.classList.remove('post-transition-settled'), 220);
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export default function ReplyList({ postId, onRefresh }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ marginTop: 20, fontSize: 14, color: '#64748b' }}>
|
||||
<div className="post-reply-count" style={{ marginTop: 20, fontSize: 14, color: '#64748b' }}>
|
||||
<Icon name="message" size={14} /> {replies.length} 条回复
|
||||
</div>
|
||||
<div style={{ marginTop: 12 }}>
|
||||
|
||||
Reference in new issue
Block a user