Skip to content

Instantly share code, notes, and snippets.

@leochocolat
Created November 4, 2020 17:30
Show Gist options
  • Save leochocolat/1c91eda9c4e4693a4bcef6d62c1b705a to your computer and use it in GitHub Desktop.
Save leochocolat/1c91eda9c4e4693a4bcef6d62c1b705a to your computer and use it in GitHub Desktop.
setupScrollParagraph() {
let scrollParagraph = this.$el.querySelector('.js-scroll-paragraph');
let originalContent = scrollParagraph.innerHTML;
let splits = new SplitText(scrollParagraph, {
type: 'lines',
linesClass: 'line-container line-container--++',
});
let lines = [];
for (let i = 0; i < splits.lines.length; i++) {
const element = splits.lines[i];
let line = new SplitText(element, {
type: 'lines',
linesClass: 'line line--++',
}).lines;
lines.push(line[0]);
}
lines[lines.length - 1].addEventListener('transitionend', () => {
scrollParagraph.innerHTML = splits.originalHTML;
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment