Каталог файловtilda-animation-2.0.js
1001/**1002 * Delete animated elements. Called inside t_animate__animateOnScroll1003 * @param {HTMLElement[]} animGroupsBlocks - list of animation chain blocks1004 * @param {HTMLElement[]} animElems - list of animation chain blocks1005 * @returns1006 */1007function t_animate__deleteAnimatedEls(animGroupsBlocks, animElems) {1008 var viewTop = window.pageYOffset;1009 var newAnimGroupsBlocks = [];1010 var newAnimElems = [];1011 animGroupsBlocks.forEach(function (animGroupsBlock) {1012
История файла и сравнение версий
if (animGroupsBlock.curTopOffset <= viewTop) {
1013 var animateElList = animGroupsBlock.querySelectorAll('.t-animate'); 1014 Array.prototype.forEach.call(animateElList, function (animateEl) { 1015 t_animate__removeAnimationClass(animateEl, ['wait', 'no-hover']); 1018 newAnimGroupsBlocks.push(animGroupsBlock); 1021 animElems.forEach(function (animElem) { 1022 if (animElem.curTopOffset <= viewTop) { 1023 t_animate__removeAnimationClass(animElem, ['wait', 'no-hover']); 1024 t_animate__startElementAnimation(animElem, false); 1026 newAnimElems.push(animElem); 1029 return [newAnimElems, newAnimGroupsBlocks]; 1033 * Animate chain blocks. (part of t_animate__animateChainsBlocks) 1034 * @param {HTMLElement & {itemsOffsets}} curBlock - current block 1035 * @param {number} viewBottom - bottom position of viewport 1037function t_animate__animateChainItemsOnScroll(curBlock, viewBottom) { 1038 var waitingChainItems = curBlock.querySelectorAll('.t-animate_wait[data-animate-chain=yes]'); 1039 waitingChainItems = Array.prototype.slice.call(waitingChainItems); 1042 var rowOffset = curBlock.itemsOffsets[0]; 1043 var chainDelay = 0.16; 1044 var delayFromPrevScroll = t_animate__getDelayFromPreviousScrollEvent(curBlock, chainDelay); 1045 var sectionHeadDelay = t_animate__getSectionHeadDealy(curBlock); 1046 // we add class t-animate__chain_first-in-row to items, to let the new row be animated as soon, as the first element in 1047 // previous row is animated 1048 if (waitingChainItems.length) waitingChainItems[0].classList.add('t-animate__chain_first-in-row'); 1049 for (var s = 0; s < waitingChainItems.length; s++) { 1050 var item = waitingChainItems[s]; 1051 var itemTopOffset = curBlock.itemsOffsets[s]; 1052 if (itemTopOffset < viewBottom) { 1053 if (itemTopOffset !== rowOffset) { 1054 // if we check next row at the same scroll event 1055 item.classList.add('t-animate__chain_first-in-row'); 1057 // itemOrder = rowOrder - next row animation starts earlier, right after first item in prevoius one 1058 itemOrder = rowOrder; 1059 rowOffset = itemTopOffset; 1061 // start item animation, set delay 1062 var curItemDelay = itemOrder * chainDelay + delayFromPrevScroll + sectionHeadDelay; 1063 item.style.transitionDelay = curItemDelay + 's'; 1064 item.classList.remove('t-animate_wait'); 1065 t_animate__startElementAnimation(item, false); 1066 item.setAttribute('data-animate-start-time', Date.now() + curItemDelay * 1000); 1067 if (item[0] === waitingChainItems[waitingChainItems.length - 1]) { 1068 t_animate__checkSectionButtonAnimation(curBlock, curItemDelay); 1070 if (+itemTopOffset === +rowOffset) { 1073 // remove animated cached chain items and offsets 1074 waitingChainItems.splice(s, 1); 1075 curBlock.itemsOffsets.splice(s, 1); 1081 t_animate__catchTransitionEndEvent(curBlock); 1085 * Get section head delay. Used for chain blocks only 1087 * @param {HTMLElement} curBlock - current element 1088 * @returns {number} - section head delay 1090function t_animate__getSectionHeadDealy(curBlock) { 1091 var sectionTitle = curBlock.querySelector('.t-section__title.t-animate'); 1092 var sectionDescr = curBlock.querySelector('.t-section__descr.t-animate'); 1093 var sectionHeadDelay = 0; 1095 var titleStartTime = sectionTitle.getAttribute('data-animate-start-time') || 0; 1096 if (Date.now() - titleStartTime <= 160) { 1097 sectionHeadDelay = 0.16; 1098 return sectionHeadDelay;