javascript - undersating page transition vs normal animations - Stack Overflow

Hello there I'm trying to understand the difference between page transition and normal page animat

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745355707a4624102.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信