reset gsap provider to music page version
This commit is contained in:
@@ -2,13 +2,12 @@
|
|||||||
import { useGSAP } from '@gsap/react'
|
import { useGSAP } from '@gsap/react'
|
||||||
import gsap from 'gsap'
|
import gsap from 'gsap'
|
||||||
import { SplitText } from 'gsap/SplitText'
|
import { SplitText } from 'gsap/SplitText'
|
||||||
import { ScrollTrigger, GSDevTools } from 'gsap/all'
|
import { ScrollTrigger } from 'gsap/all'
|
||||||
import { createContext, useCallback, useContext, useEffect, useRef, type ReactNode } from 'react'
|
import { createContext, useCallback, useContext, useEffect, useRef, type ReactNode } from 'react'
|
||||||
|
|
||||||
gsap.registerPlugin(useGSAP)
|
gsap.registerPlugin(useGSAP)
|
||||||
gsap.registerPlugin(ScrollTrigger)
|
gsap.registerPlugin(ScrollTrigger)
|
||||||
gsap.registerPlugin(SplitText)
|
gsap.registerPlugin(SplitText)
|
||||||
gsap.registerPlugin(GSDevTools)
|
|
||||||
const GsapContext = createContext<{
|
const GsapContext = createContext<{
|
||||||
addAnimation: (
|
addAnimation: (
|
||||||
animation: gsap.core.TimelineChild,
|
animation: gsap.core.TimelineChild,
|
||||||
@@ -23,7 +22,7 @@ export function useGsapContext() {
|
|||||||
return useContext(GsapContext)
|
return useContext(GsapContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useTimeLine = (dep:any,all?:boolean) => {
|
export const useTimeLine = (dep?:any,all?:boolean) => {
|
||||||
const gsapContext = useGsapContext()
|
const gsapContext = useGsapContext()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dep instanceof Array && all) {
|
if (dep instanceof Array && all) {
|
||||||
@@ -67,6 +66,7 @@ export default function GsapProvider({ children }: { children: ReactNode }) {
|
|||||||
tl.current?.add(animation, position);
|
tl.current?.add(animation, position);
|
||||||
},[])
|
},[])
|
||||||
const resetTimeline = useCallback(() => {
|
const resetTimeline = useCallback(() => {
|
||||||
|
console.log('resetting timeline')
|
||||||
tl.current?.kill()
|
tl.current?.kill()
|
||||||
tl.current?.revert()
|
tl.current?.revert()
|
||||||
ScrollTrigger.getAll().forEach(st => st.kill())
|
ScrollTrigger.getAll().forEach(st => st.kill())
|
||||||
|
|||||||
Reference in New Issue
Block a user