Каталог файловtilda-animation-sbs-1.0.js
4201 });4202 4203 animatedObject.clickedTriggerEls.forEach(function (el) {4204 el.removeEventListener('click', t_animationSBS__initClickCallback);4205 t_animationSBS__removeTriggerList(el, 'click');4206 });4207 4208 animatedObject.hoverTriggerEls.forEach(function (el) {4209 el.removeEventListener('click', t_animationSBS__initHoverTrigger);4210 el.removeEventListener('mouseenter', t_animationSBS__initHoverTrigger);4211 el.removeEventListener('mouseleave', t_animationSBS__initHoverTrigger);
История файла и сравнение версий
t_animationSBS__removeTriggerList(el, 'hover');
4215 t_animationSBS__updateAnimatedObjectState(animatedObject, 'clickedTriggerEls', []); 4216 t_animationSBS__updateAnimatedObjectState(animatedObject, 'hoverTriggerEls', []); 4219function t_animationSBS__removeTriggerList(element, type) { 4220 if (element['triggerList-on-' + type]) element['triggerList-on-' + type] = []; 4221 if (element['triggerOnceList-on-' + type]) element['triggerOnceList-on-' + type] = []; 4224//============================ on action animation: hover and click ============================// 4227 * init animation with click 4229 * @param {animatedObject} animatedObject - options 4231function t_animationSBS__initClickTriggers(animatedObject) { 4232 var clickedElements = animatedObject.elements.filter(function (el) { 4233 return el.getAttribute('data-animate-sbs-event') === 'click'; 4235 if (!clickedElements.length) return; 4236 t_animationSBS__connectTriggersWithAnimEls(clickedElements); 4237 var triggerClickElements = Array.prototype.slice.call(document.querySelectorAll('.js-sbs-anim-trigger_click')); 4238 if (!triggerClickElements.length) return; 4240 // if element has class .js-sbs-anim-trigger_click, set style cursor: pointer; 4241 if (!document.getElementById('js-sbs-anim-trigger-styles')) { 4242 var clickStyles = document.createElement('style'); 4243 clickStyles.id = 'js-sbs-anim-trigger-styles'; 4244 clickStyles.textContent = '.js-sbs-anim-trigger_click { cursor: pointer; }'; 4245 document.head.insertAdjacentElement('beforeend', clickStyles); 4248 animatedObject.clickedTriggerEls = triggerClickElements; 4249 // remove old listener, and set new one 4250 triggerClickElements.forEach(function (triggerClickElement) { 4251 t_animationSBS__preventAnimatedParentTrigger(triggerClickElement); 4252 triggerClickElement.removeEventListener('click', t_animationSBS__initClickCallback); 4253 triggerClickElement.addEventListener('click', t_animationSBS__initClickCallback); 4258 * trigger and start animation by click 4260function t_animationSBS__initClickCallback() { 4261 var triggerList = this['triggerList-on-click'] || []; 4262 var triggerOnceList = this['triggerOnceList-on-click'] || []; 4264 if (!triggerList.length && !triggerOnceList.length) return; 4265 t_animationSBS__playOnceAnimation(this, triggerOnceList, 'click'); 4267 triggerList.forEach(function (element) { 4268 if (element.classList.contains('t-sbs-anim_started') && !element.classList.contains('t-sbs-anim_reversed')) { 4269 t_animationSBS__setActionOnEnd(element); 4271 t_animationSBS__setActionOnStart(element); 4276function t_animationSBS__playOnceAnimation(currentEl, triggerOnceList, type) { 4277 if (!triggerOnceList || !triggerOnceList.length) return; 4278 t_animationSBS__actionOnStart(triggerOnceList); 4279 var event = document.createEvent('Event'); 4280 event.initEvent('updateAnimOnce', true, true); 4281 triggerOnceList.forEach(function (el) { 4282 el.dispatchEvent(event); 4284 currentEl['triggerOnceList-on-' + type] = []; 4289 * @param {animatedObject} animatedObject - options 4291function t_animationSBS__initHoverTriggers(animatedObject) { 4292 var hoveredElements = animatedObject.elements.filter(function (el) { 4293 return el.getAttribute('data-animate-sbs-event') === 'hover'; 4295 if (!hoveredElements.length) return; 4296 t_animationSBS__connectTriggersWithAnimEls(hoveredElements); 4298 // catch hover events on triggers 4299 var triggerHoverElements = document.querySelectorAll('.js-sbs-anim-trigger_hover'); 4300 triggerHoverElements = Array.prototype.slice.call(triggerHoverElements);