OlafvdH Posted June 3 Posted June 3 Hey, I have a problem with split text on mobile. If I resize my desktop screen to mobile size the problem does not apply, possibly because the height of the website does not change and on my mobile browser it does. Attached a video for demonstration, the live link and also the separate js / css. Has anyone experienced this before? Link: https://olafs-dapper-site-9ca308.webflow.io/ [data-split] > span { display: inline-block; white-space: normal; vertical-align: baseline; } .u-text-style-h1 > span { transition: all 0.6s cubic-bezier(0.25, 0.1, 0.25, 1); } .u-text-style-h1.loaded-class > span { transform: translateY(100%); opacity: 0; } let lenis; function debounce(func, delay) { let timeout; return function () { clearTimeout(timeout); timeout = setTimeout(func, delay); }; } function initLenis() { lenis = new Lenis(); // Synchronize Lenis scrolling with GSAP's ScrollTrigger plugin lenis.on('scroll', ScrollTrigger.update); // Add Lenis's requestAnimationFrame (raf) method to GSAP's ticker // This ensures Lenis's smooth scroll animation updates on each GSAP tick gsap.ticker.add((time) => { lenis.raf(time * 1000); // Convert time from seconds to milliseconds }); // Disable lag smoothing in GSAP to prevent any delay in scroll animations gsap.ticker.lagSmoothing(0); } function initSplit() { return new Promise(resolve => { const wrapWithMask = item => { const mask = document.createElement('span'); mask.setAttribute('data-split-mask-el', ''); item.parentNode.insertBefore(mask, item); mask.appendChild(item); }; const split = () => { document.querySelectorAll('[data-split]').forEach(el => { if (el._splitTextInstance) { el._splitTextInstance.revert(); delete el._splitTextInstance; } el.querySelectorAll('[data-split-mask-el]').forEach(mask => mask.remove()); const type = el.getAttribute('data-split'); const splitType = type === 'chars' ? 'words,chars' : type; const splitInstance = new SplitText(el, { type: splitType, tag: 'span', wordDelimiter: ' ' }); el._splitTextInstance = splitInstance; if (el.hasAttribute('data-split-mask')) { const key = type === 'chars' ? 'chars' : type; (splitInstance[key] || []).forEach(wrapWithMask); } }); resolve(); }; const debouncedSplit = debounce(split, 200); window.addEventListener('resize', debouncedSplit); if (document.fonts && document.fonts.ready) { document.fonts.ready.then(split); } else { window.addEventListener('load', split); } }); } function initTransitionDelay() { function transitionDelay() { document.querySelectorAll('[data-td]').forEach(element => { const delay = (parseFloat(element.getAttribute('data-td')) || 100) / 1000; const startDelay = (parseFloat(element.getAttribute('data-td-start')) || 0) / 1000; const splitType = element.getAttribute('data-split'); let spans = []; if (element.querySelector('[data-split-mask-el]')) { spans = element.querySelectorAll('[data-split-mask-el] > span'); } else { spans = element.querySelectorAll('span'); } spans.forEach((span, index) => { const currentDelay = index * delay + startDelay; span.style.transitionDelay = `${currentDelay}s`; }); }); } const debouncedTransitionDelay = debounce(transitionDelay, 200); window.addEventListener('resize', debouncedTransitionDelay); transitionDelay(); } function initFading() { const elements = [ { selector: "[data-fade-in]", init: el => gsap.set(el, { autoAlpha: 0, y: 60 }), action: el => { gsap.to(el, { autoAlpha: 1, y: 0, duration: 0.5, ease: "cubic-bezier(0.5, 0, 0, 1)" }); } }, { selector: "[data-loaded-class]", init: null, action: el => el.classList.remove( "loaded-class") }]; elements.forEach(({ selector, init, action }) => { document.querySelectorAll(selector).forEach(el => { if (init) init(el); ScrollTrigger.create({ trigger: el, start: "top 80%", onEnter: () => action(el), onEnterBack: () => action(el) }); }); }); ScrollTrigger.refresh(); } initLenis(); initSplit().then(() => { initTransitionDelay(); initFading(); }); Screen Recording Jun 3 2025.mov
OlafvdH Posted June 3 Author Posted June 3 Update: just tested on Safari and the problem is there on desktop too.
GSAP Helper Posted June 3 Posted June 3 Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer. See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen. that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: Using a framework/library like React, Vue, Next, etc.? CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import GSAP as shown in the Install Helper in our Learning Center : React (please read this article!) Next Svelte Sveltekit Vue Nuxt Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. ✅
Solution OlafvdH Posted June 4 Author Solution Posted June 4 When creating the codepen I noticed it worked there. After quite a bit of testing and minimizing the code I found that there was a text-wrap balance somewhere on the headings, now it works. Thanks! 1
OlafvdH Posted June 4 Author Posted June 4 (This style is set by default in Lumos on .u-text-style-h1)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now