Я использую next js с пакетом next-transition-router, чтобы создать анимацию перехода, работающую совершенно нормально и как и ожидалось.
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 (
{
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}
)
}
Код: Выделить всё
.layer {
background-color: var(--theme-secondary);
inset: 0;
position: fixed;
transform: translateY(100%);
z-index: 2;
}
https://watson.la/
есть фоновая простая анимация, которая идет снизу вверх, в то время как все остальное на заднем плане исчезает, это анимация страницы или переход страницы? и могу ли я реализовать это в моей текущей настройке?
Подробнее здесь: https://stackoverflow.com/questions/793 ... animations
Мобильная версия