1101if (sectionDescr) {1102var descrStartTime = sectionDescr.getAttribute('data-animate-start-time') || 0;1103if (Date.now() - descrStartTime <= 160) {1104sectionHeadDelay = 0.16;1105return sectionHeadDelay;1106}1107}1108return sectionHeadDelay;1109}11101111/**1112* In this function we count delay, if chain items from this block on previous scroll event didn't finish its transition
* * @param {HTMLElement} curBlock - current element * @param {number} chainDelay - chain delay * @returns {number} - number of delay */function t_animate__getDelayFromPreviousScrollEvent(curBlock, chainDelay) { var isFirstRow = !curBlock.querySelectorAll('.t-animate_started').length; var notAnimated = curBlock.querySelectorAll('.t-animate__chain_first-in-row.t-animate_started'); notAnimated = Array.prototype.filter.call(notAnimated, function (notAnim) { return !notAnim.classList.contains('t-animate__chain_showed'); }); // return, if it is the first element in chain or all the items are already animated if (isFirstRow || !notAnimated.length) { return 0; } if (notAnimated.length) { var lastNotAnimated = notAnimated[notAnimated.length - 1]; var lastNotAnimatedStart = lastNotAnimated.getAttribute('data-animate-start-time') || 0; var timeGap = lastNotAnimatedStart - Date.now(); if (timeGap <= 0) { return chainDelay; } else { return timeGap / 1000 + chainDelay; } }}/** * Start element animation * @param {HTMLElement} element - current element * @param {boolean} needUpdateParent - whether to update the parent element */function t_animate__startElementAnimation(element, needUpdateParent) { t_animate__prepareTextAnimation(element); t_animate__setStartAnimationClass(element, needUpdateParent);}/** * Set start animation class to element * @param {HTMLElement} element - current element * @param {boolean} needUpdateParent - whether to update the parent element */function t_animate__setStartAnimationClass(element, needUpdateParent) { if (!element) return; if (needUpdateParent) { var fixedAnimationParentClassName = 't-animate-for-wrapper'; var fixedAnimationParent = element.closest('.' + fixedAnimationParentClassName); if (fixedAnimationParent) fixedAnimationParent.classList.remove(fixedAnimationParentClassName); } element.classList.add('t-animate_started'); const isFadeInLeft = element.getAttribute('data-animate-style') === 'fadeinleft'; if (isFadeInLeft) { const parentElement = element.closest('.t-animate__overflow-x-hidden'); if ( parentElement && !parentElement.querySelector('[data-animate-style="fadeinleft"]:not(.t-animate_started)') ) { parentElement.classList.remove('t-animate__overflow-x-hidden'); } }}/** * Animate chain blocks on event (transitionend) * * @param {HTMLElement} curBlock - current element */function t_animate__catchTransitionEndEvent(curBlock) { var animateChainList = curBlock.querySelectorAll('.t-animate__chain_first-in-row.t-animate_started'); animateChainList = Array.prototype.filter.call(animateChainList, function (animChain) { return !animChain.classList.contains('t-animate__chain_showed'); }); Array.prototype.forEach.call(animateChainList, function (animateChain) { var events = ['transitionend', 'webkitTransitionEnd', 'oTransitionEnd', 'otransitionend', 'MSTransitionEnd']; events.forEach(function (event) { animateChain.addEventListener(event, function () { t_animate__addEventOnAnimateChain(animateChain); }); animateChain.removeEventListener(event, function () { t_animate__addEventOnAnimateChain(animateChain); }); }); });}/* ---------- functions, for animated number ---------- */