admin管理员组文章数量:1421688
Hello there I'm trying to understand the difference between page transition and normal page animations I use next js with a package called next-transition-router to create a transition animation that works totally fine and as expected
transition.tsx
'use client'
import { gsap } from 'gsap'
import { TransitionRouter } from 'next-transition-router'
import { useRef } from 'react'
import s from './transition.module.css'
export function Transition({ children }: { children: React.ReactNode }) {
const layerRef = useRef(null)
return (
<TransitionRouter
auto
leave={(next) => {
const tween = gsap.fromTo(
layerRef.current,
{ y: '100%' },
{
duration: 0.8,
y: 0,
ease: 'power2.inOut',
onComplete: next,
}
)
return () => tween.kill()
}}
enter={(next) => {
const tween = gsap.fromTo(
layerRef.current,
{ y: 0 },
{
duration: 0.8,
y: '-100%',
ease: 'power2.inOut',
onComplete: next,
}
)
return () => tween.kill()
}}
>
{children}
<div ref={layerRef} className={s.layer} />
</TransitionRouter>
)
}
styles
.layer {
background-color: var(--theme-secondary);
inset: 0;
position: fixed;
transform: translateY(100%);
z-index: 2;
}
I notice on this website
/
There is a background simple animation that comes from bottom to top while everything else in the background fades away, is this a page animation or a page transition? can I implement that in my current setup?
本文标签: javascriptundersating page transition vs normal animationsStack Overflow
版权声明:本文标题:javascript - undersating page transition vs normal animations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745355707a2655037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论