Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142129

Turning into paragraph

$
0
0

I'm turning all characters and whitespaces into spans from paragraph and I'm animating those spans with gsap. The problem is, that the different letters lost connection with words and im getting a bad looking paragraph.

     const quote = document.querySelector('.paragraph');
     const quoteText = quote.textContent;
     quote.innerHTML = quote.textContent.replace(
      /\S/g,
      "<span class='letter'>$&</span>"
    );

    const tl = new TimelineMax();
      tl.staggerFrom(
      quote.childNodes,
      1,
      { opacity: 0, y: 200, ease: Power4.easeOut },
      0.02,
      () => {
        quote.textContent = quoteText;
      }
    );


Then, when animation completes I'm assigning a previous paragraph text content, but the letters move and its not looking good. What is a proper way of doing my animation?


Viewing all articles
Browse latest Browse all 142129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>