Каталог файловtilda-animation-sbs-1.0.js
2001 var animLoopAttribute = animatedObject.isEditMode ? 'data-field-sbsloop-value' : 'data-animate-sbs-loop';2002 animatedHTML.loop = animatedHTML.getAttribute(animLoopAttribute) || '';2003 2004 // записывает в элемент параметры:2005 // el.parentRecTopPos - абсолютная позиция верха родительской записи2006 // el.topOffset - абсолютная позиция верха элемента2007 // el.triggerOffset - позиция триггера, включает topOffset2008 // и зависит от выбранного триггера старта: верх/центр/низ окна2009 t_animationSBS__setAndCacheElTopPos(animatedHTML, animatedObject);2010 2011
История файла и сравнение версий
// шаги из data-атрибута складываются в массив element.steps
2012 var zoomValue = t_animationSBS__getZoom(animatedHTML); 2013 animatedHTML.steps = []; 2014 var totalUnfixedDist = 0; 2016 elemAnimSteps.forEach(function (step, i) { 2018 stepObj.state = 'unactive'; 2019 stepObj.styles = t_animationSBS__createStepStyles(step); 2021 if (animatedHTML.animType === 'scroll') { 2022 stepObj.prevUnfixedDist = totalUnfixedDist; 2023 stepObj.dist = step.di * zoomValue; // step.di - дистанция в px 2024 if (stepObj.styles.fix === false) totalUnfixedDist += stepObj.dist; // stepObj.styles.fix - step.fi === 'fixed' 2025 stepObj.start = i === 0 ? animatedHTML.topOffset : animatedHTML.steps[i - 1].end; 2026 stepObj.end = stepObj.start + stepObj.dist; 2028 stepObj.time = step.ti; // step.ti - длительность в мс 2029 stepObj.ease = step.ea; // '' | 'easeIn' | 'easeOut' | 'easeInOut' | 'bounceFin' 2032 animatedHTML.steps.push(stepObj); 2035 if (animatedHTML.wrapperEl && (!animatedHTML.wrapperEl.id || !animatedHTML.uniqueID)) { 2036 t_animationSBS__generateUniqueIDForEl(animatedHTML); 2038 t_animationSBS__updateInfoOnImgLoad(animatedHTML, animatedObject); 2039 t_animationSBS__updateMoveAndRotateStepsStyles(animatedHTML.steps); 2040 // после generateUniqueIDForEl: селекторы слоя фона строятся от id обертки 2041 t_animationSBS__setColorTargets(animatedHTML, animatedObject.isEditMode); 2044 // удаляем из списка элементы без анимации 2045 var onlyProcessedAnimEls = animatedObject.elements.filter(function (el) { 2046 if (el.status === 'innactive') { 2047 const { width, height } = t_animationSBS__getSizeBasedOnDimensionMode(el); 2049 if (el.wrapperEl) el.wrapperEl.removeAttribute('style'); 2050 if (el.wrapperEl) el.wrapperEl.style.display = 'inherit'; 2051 if (el.wrapperEl) el.wrapperEl.style.width = width; 2052 if (el.wrapperEl) el.wrapperEl.style.height = height; 2054 return el.status !== 'innactive'; 2056 t_animationSBS__updateAnimatedObjectState(animatedObject, 'elements', onlyProcessedAnimEls); 2060 * create uniqueID to set selector and animation name for animation @keyframes. 2061 * Set uniqueID to wrapperEl id. 2062 * Update ID (if they exist) to remove cache in @keyframes in Safari 2064 * @param {AnimatedHTML} animatedHTML 2066function t_animationSBS__generateUniqueIDForEl(animatedHTML) { 2067 var artBoard = animatedHTML.closest('.t396__artboard, .tn-artboard'); 2069 if (artBoard) recID = artBoard.getAttribute('data-record-id') || artBoard.getAttribute('data-artboard-recid'); 2070 const { id } = t_animationSBS__getAttributeSelector(animatedHTML); 2071 animatedHTML.uniqueID = 'sbs-' + recID + '-' + id; 2072 animatedHTML.wrapperEl.id = animatedHTML.uniqueID; 2076 * update info img onload 2078 * @param {AnimatedHTML} element - current element 2079 * @param {animatedObject} opts - options 2081function t_animationSBS__updateInfoOnImgLoad(element, opts) { 2082 var image = element.querySelector('img'); 2084 image.addEventListener('load', function () { 2085 t_animationSBS__updateValuesAterIMGLoading(element, opts); 2087 if (image.complete) { 2088 t_animationSBS__updateValuesAterIMGLoading(element, opts); 2093 * @param {AnimatedHTML} element - current element 2094 * @param {animatedObject} animatedObject - options 2096function t_animationSBS__updateValuesAterIMGLoading(element, animatedObject) { 2097 t_animationSBS__setAndCacheElTopPos(element, animatedObject); 2098 if (element.animType === 'scroll') t_animationSBS__updateStepsValues(element);