Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
Журнал изменений История Git Файлы Tilda MCP Каталог файловtilda-cover-1.0.js Следить за файлом 601 602 /**603 * this function responsible for recalculating the height of the cover,604 * if the content inside the cover has a highter height then set605 *606 * @param {string} id - of inited record607 * @param {boolean} isOrientationChange - if orientation change - true608 */609 function t_cover__recalcCoverHeight(id, isOrientationChange) {610 var rec = document.getElementById('rec' + id);611 if (!rec) return;612 История файла и сравнение версий const isScaled = t_cover__isScaled(rec);
613 var cover = rec.querySelector('.t-cover');614 var recordType = rec.getAttribute('data-parenttplid') || rec.getAttribute('data-record-type');615 if (!cover || recordType === '935') return; // don't process Tilda Main Page cover617 var coverCarrier = rec.querySelector('.t-cover__carrier');618 var coverSetByUserHeight = coverCarrier ? coverCarrier.getAttribute('data-content-cover-height') : '';619 if (!coverSetByUserHeight) {620 var coverHeightElem = rec.querySelector('[data-content-cover-height]');621 coverSetByUserHeight = coverHeightElem ? coverHeightElem.getAttribute('data-content-cover-height') : '';623 var isFixedBgEarly = rec.getAttribute('data-fixed-bg') === 'y';624 var selectorsList = ['.t-cover', '.t-cover__filter', '.t-cover__carrier', '.t-cover__wrapper'];626 // for support CR30N (querySelector need for Edit-mode)627 if (recordType === '734' || rec.querySelector('.t734')) selectorsList.push('.t-slds__items-wrapper');629 var isParallax = coverCarrier.getAttribute('data-content-cover-parallax') === 'dynamic';630 var elHeight = t_cover__getHeightFromAttr(coverSetByUserHeight);633 const processedHeight = `${Math.round(elHeight)}px`;634 const finalHeight = isScaled ? `calc(${processedHeight} / var(--t-zoom, 1))` : processedHeight;635 selectorsList.forEach(function (selector) {636 if (isParallax && selector === '.t-cover__carrier') return;637 var elementList = Array.prototype.slice.call(rec.querySelectorAll(selector));638 elementList.forEach(function (element) {639 if (element) element.style.height = finalHeight;644 var heightSetByUser = t_cover__getHeightFromAttr(coverSetByUserHeight);645 var calculatedHeight = t_cover__getPureHeight(cover);646 var coverHeight = heightSetByUser || calculatedHeight;648 // if it is not cover with fixed parallax, calculate pure cover height without appended height after previous calculation649 if (!isFixedBgEarly) {650 var cachedCoverHeight = cover.style.height;651 cover.style.height = '';652 coverHeight = calculatedHeight;653 if (cachedCoverHeight) cover.style.height = cachedCoverHeight;656 var contentHeight = t_cover__getContentHeight(rec);657 var coverPadding = 40;658 var minCheckedContentHeight = 300;659 var isCoverFullVH = coverCarrier ? coverCarrier.getAttribute('data-content-cover-height') === '100vh' : false;661 // if content highter then cover height; if cover has fixed bg in Safari662 if ((contentHeight > minCheckedContentHeight && coverHeight < contentHeight + coverPadding) || isFixedBgEarly) {663 t_cover__setRecalculatedHeight(rec, contentHeight);664 t_cover__updateResizeElem(rec);665 } else if ((window.t_cover__isMobile || 'ontouchend' in document) && isOrientationChange) {666 t_cover__setRecalculatedHeight(rec, contentHeight);667 t_cover__updateResizeElem(rec);668 } else if (window.t_cover__isMobile && isCoverFullVH) {669 selectorsList.forEach(function (selector) {670 var element = rec.querySelector(selector);671 if (element) element.style.height = document.documentElement.clientHeight + 'px';673 } else if (coverHeight > contentHeight + coverPadding) {674 // исправляет ошибку, когда после условия: coverHeight < contentHeight + coverPadding675 // высота cover_carrier больше не обновлялась676 t_cover__setRecalculatedHeight(rec, contentHeight);677 t_cover__updateResizeElem(rec);681 function t_cover__getContentHeight(rec) {682 var contentList = Array.prototype.slice.call(rec.querySelectorAll('div[data-hook-content]'));683 if (contentList.length <= 1) return t_cover__getPureHeight(contentList[0]);686 var contentHeight = contentList.map(function (content) {687 return t_cover__getPureHeight(content);689 contentHeight.sort(function (a, b) {692 // return max possible height from content list693 return contentHeight[0] || 0;697 * get height from data-attribute699 * @param {string} height700 * @return {number} - calculated height