PluginProbe
Themify Builder / trunk
Themify Builder vtrunk
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / themify / js / modules / animate.js

animate.js in Themify Builder trunk, at themify/js/modules/animate.js

1 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ((t,e,o)=>{"use strict";const i=function(){if(!0!==this.tbAnimating){this.tbAnimating=!0;const t=this.style,e=t.animationName,o=this.dataset.tfAnimation_hover;e&&(t.animationIterationCount=t.animationDelay=t.animationName="",this.classList.remove(e)),this.tfOn("animationend",(function(t){this.classList.remove("animated","tb_hover_animate",t.animationName),this.style.animationName=this.style.willChange="",this.tbAnimating=!1}),{passive:!0,once:!0}),setTimeout((()=>{t.animationName=o,this.classList.add(o,"animated","tb_hover_animate")}),2)}},a=t=>{t&&(t.update?t.update():t.updateSize().updateSlides().updateSlidesClasses().updateAutoHeight(),t.lazyPreload?.())},n=e=>{let o=e.tfClass("tf_carousel");e.classList.contains("tf_carousel")&&(o=t.convert(o,e)),void 0!==o[0]&&requestAnimationFrame((()=>{for(let e=o.length-1;e>-1;--e){let i=o[e],n=i.swiper;i.hasAttribute("data-lazy")&&t.lazyScroll?t.lazyScroll([i],!0).finally((()=>{n=i.swiper,a(n)})):a(n)}}))},s=t=>null!==t.querySelector(".masonry,.loops-wrapper.masonry"),r=new WeakSet,m=new WeakSet,f=t=>{const o=t.getBoundingClientRect();return o.bottom>0&&o.top<e.innerHeight&&(o.height>0||o.width>0)},c=t=>(t.hasAttribute("data-tf-animation")||t.classList.contains("hover-wow")||t.classList.contains("wow"))&&!r.has(t)&&"visible"!==t.style.visibility&&"hidden"===getComputedStyle(t).visibility,d=t=>{if(t.style.visibility="visible",n(t),t.hasAttribute("data-tf-animation")){t.hasAttribute("data-tf-animation_repeat")&&(t.style.animationIterationCount=t.dataset.tfAnimation_repeat),t.hasAttribute("data-tf-animation_delay")&&(t.style.animationDelay=t.dataset.tfAnimation_delay+"s");const e=t.dataset.tfAnimation;t.classList.add(e),t.style.animationName=e,t.tfOn("animationend",(function(){this.style.animationIterationCount=this.style.animationDelay=this.style.willChange="",this.classList.remove("animated",e),this.removeAttribute("data-tf-animation"),n(this)}),{passive:!0,once:!0}).classList.add("animated")}t.classList.contains("hover-wow")&&(t=>{const e=["pointerenter","tf_custom_animate"];t.tfOff(e,i,{passive:!0}).tfOn(e,i,{passive:!0})})(t)},h=e=>{if(r.has(e))return;r.add(e);!0===(e.classList.contains("tf_carousel")||void 0!==e.tfClass("tf_carousel")[0])||s(e)?d(e):(e=>{const o=e.tfTag("img"),i=[];for(let t=o.length-1;t>-1;--t){const e=o[t];e.complete||"lazy"===e.loading||e.hasAttribute("data-lazy")||e.hasAttribute("data-tf-not-load")||i.push(e)}return 0===i.length?Promise.resolve(e):Promise.race([t.imagesLoad(i),new Promise((t=>setTimeout((()=>t(e)),2500)))])})(e).then(d)},l=t=>{if(c(t)){try{_.unobserve(t)}catch(t){}h(t)}},w=t=>{if(!t)return;let e=t.parentElement;while(e){if(c(e)){l(e);break}e=e.parentElement}const o=t.querySelectorAll("[data-tf-animation],.hover-wow");for(let t=o.length-1;t>-1;--t)l(o[t])},u=e=>{if(!s(e))return;const o=e.querySelector(".masonry,.loops-wrapper.masonry");if(!o)return;if(o.classList.contains("masonry-done"))return void l(e);const i=a=>{a.element===o&&(t.off("isolayoutComplete",i),l(e))};t.on("isolayoutComplete",i)},_=new IntersectionObserver(((t,e)=>{for(let o=t.length-1;o>-1;--o){const i=t[o].target;(!0===t[o].isIntersecting||f(i))&&(e.unobserve(i),h(i))}}),{threshold:0}),v=e=>{e?.[0]&&t.animateCss().then((()=>{for(let t=e.length-1;t>-1;--t){const o=e[t];m.has(o)?u(o):(m.add(o),o.style.willChange="transform,opacity",s(o)?(_.observe(o),u(o)):f(o)?l(o):_.observe(o))}const t=o.getElementsByClassName("masonry-done");for(let e=t.length-1;e>-1;--e)w(t[e])}))},y=(t,o)=>{!0===o&&(t=>{if(!t)return;const o=t.classList?.contains("masonry-done")?[t]:t.querySelectorAll(".masonry-done");for(let t=o.length-1;t>-1;--t){const i=e.Isotope?.data(o[t]);i&&i.layout()}})(t),w(t)};t.on("tf_wow_init",v).on("tf_wow_preview",(t=>{if(t){(void 0===t.length||t.nodeType)&&(t=[t]);for(let e=t.length-1;e>-1;--e){const o=t[e];if(!o?.hasAttribute("data-tf-animation")&&!o?.classList.contains("hover-wow"))continue;const i=o.dataset.tfAnimation;r.delete(o),m.delete(o);try{_.unobserve(o)}catch(t){}i?o.classList.remove("animated","tb_hover_animate",i):o.classList.remove("animated","tb_hover_animate"),o.style.animationName=o.style.willChange=o.style.visibility="",r.add(o),d(o)}}})).on("tf_wow_retry",(t=>{y(t,!1)})).on("tb_accordion_switch",(t=>{const e=t?.[0]||t,o=()=>{y(e,!0);let t=e?.parentElement;while(t){if(c(t)){l(t);break}t=t.parentElement}};o(),setTimeout(o,450)})).on("tb_tabs_switch",(t=>{y(t,!0)})),o.body.classList.contains("wp-admin")||v(t.selectWithParent(".hover-wow,[data-tf-animation]"))})(Themify,window,document);