SplitType icon indicating copy to clipboard operation
SplitType copied to clipboard

Preserving non-breaking spaces

Open piotr-kucharski opened this issue 3 years ago • 3 comments

It would be useful if script allowed to preserve  .

piotr-kucharski avatar Jun 06 '22 18:06 piotr-kucharski

Yeah I think that would be a useful feature.

lukePeavey avatar Jun 06 '22 21:06 lukePeavey

If anyone wants to work on this, please feel free to submit a PR.

lukePeavey avatar Jun 12 '22 05:06 lukePeavey

If you're trying to ensure there is space after each word. You can combine the two to get something close.

// Creates word wraps within the #target
const word = new SplitType('h2', {
  types: 'words',
  tagName: 'span',
  wordClass: 'word-wrap'
});

// Then, creates letter wrap within the word wrap above.
const text = new SplitType('.word-wrap', {
  types: 'chars',
  tagName: 'span',
  charClass: 'letter-wrap',
  absolute: true
});

gsap.from(text.chars, {
  opacity: 0,
  y: 400,
  duration: 2,
  ease: "power4.out",
  stagger: { amount: 2 }
})

Then adjust spacing with css.

wetsoba avatar Jul 01 '22 04:07 wetsoba