Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not splitting lines correctly #60

Open
hantastic opened this issue Apr 2, 2023 · 3 comments
Open

Not splitting lines correctly #60

hantastic opened this issue Apr 2, 2023 · 3 comments

Comments

@hantastic
Copy link

Hi,
I'm trying to split my content into lines but it appears to be splitting my paragraph instead. Any advice greatly appreciated please.

I'm using version 0.3.3 and Next.js version 13.2.4

Here's the code I'm using to split the text:

useEffect(() => {
    if (textRef.current) {
      gsap.registerPlugin(ScrollTrigger)
      const newText = new SplitType(textRef.current, { types: 'lines, words' })

      newText.lines.forEach((target) => {
        gsap.to(target, {
          backgroundPositionX: 0,
          ease: 'none',
          scrollTrigger: {
            trigger: target,
            markers: true,
            scrub: 0.5,
            start: 'top bottom',
            end: 'bottom center',
          },
        })
      })
    }
  }, [textRef])

Screenshot 2023-04-02 at 14 04 05

@lukePeavey
Copy link
Owner

lukePeavey commented Apr 2, 2023

Can you create a live example on code sandbox?

I can't really tell what's happening without seeing the complete code.

@lukePeavey
Copy link
Owner

If you can't create a live demo, include the full code of that react component, including the html element that the ref is attached to.

It would also help to see the generated html in the web inspector after the split text function runs.

@khalilonline99
Copy link

useEffect(() => {
if (textRef.current) {
gsap.registerPlugin(ScrollTrigger)
const newText = new SplitType(textRef.current, { types: 'lines, words' });

    gsap.to(newText.lines, {
      backgroundPositionX: 0,
      ease: 'none',
      scrollTrigger: {
        trigger: newText,
        markers: true,
        scrub: 0.5,
        start: 'top bottom',
        end: 'bottom center',
      },
  })
}

}, [textRef])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants