const duration = t_animate__setTextAnimationVariables(element);
2214 t_animate__prepareWordByWordAnimationToRight(element); 2215 t_animate__prepareWordByWordAnimationToLeft(element); 2216 t_animate__prepareLinesFadeInAnimation(element); 2217 t_animate__prepareLinesFadeInWrappedAnimation(element); 2218 t_animate__prepareLetterByLetterAnimation(element, duration); 2222 * Set CSS variables of ZeroBlock text animation duration and distance from data-animate-duration and data-animate-distance. 2223 * Distance is applied only to word animations without masks and gradients. 2224 * @param {HTMLElement} element - specific element to prepare 2225 * @returns {number|null} - duration in seconds, if it is set 2227function t_animate__setTextAnimationVariables(element) { 2228 if (!element.closest('.t396')) { 2232 const textAnimationStyles = [ 2233 'word-fade-in-right', 2234 'word-fade-in-left', 2235 'word-fade-in-down', 2237 'word-fade-in-up-masked', 2238 'line-fade-in-up-masked', 2239 'line-fade-in-right-gradient', 2240 'line-fade-in-left-gradient', 2241 'letter-bounce-in-up', 2243 const distanceAnimationStyles = ['word-fade-in-right', 'word-fade-in-left', 'word-fade-in-down', 'word-fade-in-up']; 2245 const elementAnimationStyle = element.getAttribute('data-animate-style'); 2247 if (!textAnimationStyles.includes(elementAnimationStyle)) { 2251 const parsedDuration = parseFloat(t_animate__getAttrByResBase(element, 'duration')); 2252 const duration = !isNaN(parsedDuration) && parsedDuration >= 0 ? parsedDuration : null; 2253 const distance = parseFloat(t_animate__getAttrByResBase(element, 'distance')); 2254 const isDistanceAllowed = distanceAnimationStyles.includes(elementAnimationStyle); 2256 if (duration !== null) { 2257 element.style.setProperty('--t-animate-text-duration', `${duration}s`); 2260 if (isDistanceAllowed && !isNaN(distance)) { 2261 element.style.setProperty('--t-animate-text-distance', `${distance}px`); 2268 * Check whether text animation particle is whitespace between words 2269 * @param {HTMLElement} particle - word, letter or whitespace element 2270 * @returns {boolean} 2272function t_animate__isWhitespaceParticle(particle) { 2273 return particle.classList.contains('t-animate__word_whitespace'); 2277 * Set animation delay to text animation particle. 2278 * Whitespace gets additional delay, so it appears after the next word or letter has started. 2279 * @param {HTMLElement} particle - word, letter or whitespace element 2280 * @param {number} delay - delay in seconds 2282function t_animate__setTextParticleDelay(particle, delay) { 2283 const whitespaceAdditionalDelay = 0.2; 2284 const particleDelay = t_animate__isWhitespaceParticle(particle) ? delay + whitespaceAdditionalDelay : delay; 2286 particle.style.animationDelay = `${particleDelay}s`; 2290 * Get animated text elements by animation styles or specific element. 2291 * @param {string[]} animationStyles - array of animation styles to filter elements 2292 * @param {HTMLElement|null} element - optional specific element to get, if null, gets all document elements with the specified animation styles 2293 * @returns {HTMLElement[]} - array of animated text elements 2295function t_animate__getAnimatedTextElements(animationStyles, element = null) { 2297 const elements = document.querySelectorAll( 2298 animationStyles.map(style => `.t-animate[data-animate-style="${style}"]`).join(', ')