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

How to adding class each line? #63

Open
reksaandhika opened this issue Sep 29, 2020 · 5 comments
Open

How to adding class each line? #63

reksaandhika opened this issue Sep 29, 2020 · 5 comments

Comments

@reksaandhika
Copy link

reksaandhika commented Sep 29, 2020

I tried use code from documentation, it's not even wrapping line, instead just splitting words. Any idea how to adding class each line so i can animating per-line not per-word, thank you.

i want something like this anyway: https://somethinggood.no/

@gibbsy
Copy link

gibbsy commented Oct 30, 2020

The lines plugin will add the --line-index css variable to each word, which you can use in your animation. For example:
span.word { transition-delay: calc(var(--line-index) * 250ms + 250ms); }

@chigggsy
Copy link

chigggsy commented Oct 31, 2020

Having trouble with splitting by lines as well. The documentation is a little confusing (pretty new to coding). Do I still add data-splitting="words" to my <p> tag?

@elebumm
Copy link

elebumm commented Mar 16, 2021

I wish this functionality existed. At the moment it just provides a CSS variable, which I can't animate using GSAP.

@chigggsy
Copy link

@elebumm I've heard you can use the GSAP SplitText plugin. However it is part of their Club Greensock membership.

@gibbsy
Copy link

gibbsy commented Mar 17, 2021

Not tested this but to animate with gsap have you tried something like:

let myTl = gsap.timeline()
let delay = 0.3 //delay between lines in seconds
let dur = 0.3 //duration of animation
let words = Array.from(document.getElementsByClassName('word'));
words.forEach(word => {
let lineNum = getComputedStyle(word).getPropertyValue('--line-index');
myTl.to(word, dur, { y:"+=10px", ease: "Power2.EaseOut" }, lineNum*delay)
})

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

No branches or pull requests

4 participants