801802if (moveX) frameMoveX += (moveX - frameMoveX) * 0.02;803if (moveY) frameMoveY += (moveY - frameMoveY) * 0.02;804805if (Math.abs(frameMoveX - moveX) < 1 && Math.abs(frameMoveY - moveY) < 1) {806stop = true;807return;808}809810if (parallaxMouseEl && parallaxMouseEl.animEl.length) {811Array.prototype.forEach.call(parallaxMouseEl.animEl, function (animatedEl) {812animatedEl.style.transform = 'translate3d(' + frameMoveX + 'px, ' + frameMoveY + 'px, 0px)';
}); } }}/** * If element has animation with transform, we can get trigger * from area from initial (cached) element position. * To prevent it - should use pointer-events. * * @param {ParallaxMouseElement} element - .t396__elem, .t396__group */function t_animateParallax__preventAnimatedParentTrigger(element) { if (getComputedStyle(element).pointerEvents === 'none') return; var elementCore = element.querySelector('.tn-molecule, .tn-atom'); if (!elementCore) return; element.style.pointerEvents = 'none'; elementCore.style.pointerEvents = 'auto';}/*============= SCROLL PARALLAX ==============*//** * init scroll for parallax animated elements * * @returns {void} */function t_animateParallax__initScroll() { var parallaxScrollElements = t_animationExt__getAnimatedElements('prx', ['scroll']); if (!parallaxScrollElements.length) return; var hiddenEls = parallaxScrollElements.filter(function (el) { return t_animationExt__isElementHidden(el); }); parallaxScrollElements.forEach(function (parallaxScrollEl) { if (!t_animationExt__isElementHidden(parallaxScrollEl)) { parallaxScrollEl.setAttribute('data-animate-prx-processed', 'true'); var elSpeed = t_animationExt__getAttrByRes(parallaxScrollEl, 'prx-s', 'data-animate-', 0); var parallaxSpeed = Math.round((parseInt(elSpeed) - 100) / 10); var parallaxWrapper = parallaxScrollEl.querySelector('.tn-atom__prx-wrapper'); if (parallaxWrapper && parallaxSpeed) parallaxWrapper.setAttribute('data-parallax-speed', parallaxSpeed.toString()); } }); if (parallaxScrollElements.length) { t_animationExt__createScrollParallax('[data-parallax-speed]'); } if (!hiddenEls.length) return; window.addEventListener( 'scroll', t_throttle(function () { var visibleElements = hiddenEls.filter(function (el, i) { if (!t_animationExt__isElementHidden(el)) { // remove from hidden elements visible child hiddenEls.splice(i, 1); // and append this child to visible elements array return true; } return false; }); if (!visibleElements.length) return; var lastVisibleEl = visibleElements[visibleElements.length - 1]; var elSpeed = t_animationExt__getAttrByRes(lastVisibleEl, 'prx-s', 'data-animate-', 0); var curSelector = 'parallax' + Date.now(); visibleElements.forEach(function (visibleEl) { var atomWrapper = visibleEl.querySelector('.tn-atom__prx-wrapper'); var parallaxSpeed = Math.round((parseInt(elSpeed) - 100) / 10); if (atomWrapper) atomWrapper.setAttribute('data-parallax-speed', parallaxSpeed.toString()); visibleEl.classList.add(curSelector); }); t_animationExt__createScrollParallax('.' + curSelector); }, 50) );}/** * find element by selector, get it offsets and create parallax. Update values by resize/orientation change * * @param {string} selector */function t_animationExt__createScrollParallax(selector) { var elements = Array.prototype.slice.call(document.querySelectorAll(selector)); if ('IntersectionObserver' in window) {