1601function t_zoom_unscale() {1602const scaleActiveClass = 'scale-active';1603const scaledItems = document.querySelectorAll(`.${scaleActiveClass}`);1604scaledItems.forEach(scaledItem => scaledItem.classList.remove(scaleActiveClass));16051606const activeSlide = document.querySelector('.t-carousel__zoomer__item.active');1607const zoomerTrack = document.querySelector('.t-carousel__zoomer__track');1608const zoomGalleryWrapper = document.querySelector('.t-zoomer__wrapper');16091610if (!activeSlide || !zoomerTrack || !zoomGalleryWrapper) return;1611
const activeImage = activeSlide.querySelector('.t-carousel__zoomer__img'); activeImage.onmousemove = null; activeImage.ontouchmove = null; activeImage.style.transform = ''; activeImage.style.left = ''; activeImage.style.top = ''; zoomerTrack.style.transform = `translateX(-${activeSlide.offsetLeft || 0}px)`; if (scaledItems.length) zoomerTrack?.setAttribute('data-cached-zoom', 'y'); // remove transition to prevent visible return to active slide setTimeout(() => { if (zoomerTrack) zoomerTrack.style.transition = ''; }, 100);}/** * * @param {'on' | 'off'} action */function t_zoom__processScrollLock(action) { const scrollLockerClass = 't-body_scroll-locked'; const scrollLockerAttribute = 'data-popup-scrolltop'; const { needLock } = t_getZoomState(); if (!needLock) return; const alreadySetLockerClass = document.body.classList.contains(scrollLockerClass); if (action === 'on' && !alreadySetLockerClass) { const bodyScrollTop = window.pageYOffset; document.body.classList.add(scrollLockerClass); document.body.style.top = `-${bodyScrollTop}px`; document.body.setAttribute(scrollLockerAttribute, bodyScrollTop); } else if (action === 'off' && alreadySetLockerClass) { const bodyScrollTop = parseInt(document.body.getAttribute(scrollLockerAttribute), 10) || 0; document.body.classList.remove(scrollLockerClass); document.body.style.top = ''; document.body.removeAttribute(scrollLockerAttribute); window.scrollTo(0, bodyScrollTop); }}/** * Генерирует объект с темой, на основе цвета фона и наличия CSS переменной * @param {string} bgColor * @param {boolean} isCSSVariable * @returns {{bgColor: string, textColor: string, isDark: boolean}} */function t_zoom__getThemePreset(bgColor = '#ffffff', isCSSVariable = false) { const WHITE = '#ffffff'; const BLACK = '#000000'; const bgColorRGBA = bgColor.includes('-gradient(') ? t_zoom_getFirstColorFromGradient(bgColor) : t_zoom_hexToRGBA(bgColor); const isDark = t_zoom_luma_rgba(bgColorRGBA) === 'black'; let currentBackground = bgColor; if (!isCSSVariable) currentBackground = isDark ? BLACK : WHITE; return { isDark, bgColor: currentBackground, textColor: isDark ? WHITE : BLACK, };}/** * Получение цветов для модального окна зума из всевозможных источников: css-переменная, родитель, сниппет или попап * * @param {HTMLElement} parent - родительская запись rec * @param {HTMLElement} targetElement - текущий элемент * @returns {{bgColor: string, textColor: string, isDark: boolean}} */function t_zoom__getModalColors(parent, targetElement) { const styles = getComputedStyle(document.body); const cssVariableBgColor = styles.getPropertyValue('--t-zoom-gallery-bg-color').trim(); if (cssVariableBgColor) { return t_zoom__getThemePreset(cssVariableBgColor, true); } // Получаем цвет из атрибута родителя let parentBGColor = parent.getAttribute('data-bg-color') || '#ffffff'; // Проверяем сниппет const isSnippet = document.getElementById('allrecords') !== document.querySelector('.t-catalog__product-snippet, .t-store__product-snippet') &&