PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.6.1
Block Animations, Motion & Scroll Effects – Ghost Kit v3.6.1
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / build / gutenberg / blocks / video / frontend.js

frontend.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.6.1, at build/gutenberg/blocks/video/frontend.js

1 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{const{GHOSTKIT:{events:e},Motion:{animate:t}}=window;function o(e){t(e,{opacity:[0,1],display:"flex"},{duration:.2,display:{duration:0}})}e.on(document,"init.blocks.gkt",(()=>{void 0!==window.VideoWorker&&document.querySelectorAll(".ghostkit-video:not(.ghostkit-video-ready)").forEach((i=>{i.classList.add("ghostkit-video-ready"),e.trigger(i,"prepare.video.gkt");const s=i.getAttribute("data-video"),a=i.getAttribute("data-click-action"),r="true"===i.getAttribute("data-video-autoplay"),d="true"===i.getAttribute("data-video-autopause"),l="true"===i.getAttribute("data-video-loop"),n=i.querySelector(".ghostkit-video-fullscreen-close-icon")?.innerHTML||"",c=i.getAttribute("data-fullscreen-video-background-color"),g=i.getAttribute("data-fullscreen-video-background-gradient"),u=i.getAttribute("data-fullscreen-background-color"),p=i.getAttribute("data-fullscreen-background-gradient");let v=i.querySelector(".ghostkit-video-poster"),k=!1,f=0,y=i.getAttribute("data-video-aspect-ratio");const b=y.split(":")[0],m=y.split(":")[1];y=y&&b&&m?b/m:16/9,parseFloat(i.getAttribute("data-video-volume"))||(f=1),r&&(f=1);const h={autoplay:0,loop:l,mute:f,volume:parseFloat(i.getAttribute("data-video-volume"))||0,showContols:1};e.trigger(i,"prepare.videoWorker.gkt",{options:h});const L=new window.VideoWorker(s,h);if(e.trigger(i,"prepared.videoWorker.gkt",{api:L}),L&&L.isValid()){let s=0,l=0,f=!1;const y=()=>{l||(l=1,"fullscreen"===a?s?k&&(i.classList.remove("ghostkit-video-fullscreen-closed"),o(k),L.play()):(i.classList.add("ghostkit-video-loading"),L.getVideo((s=>{const a=s.parentNode,r=document.createElement("div");r.classList.add("ghostkit-video-fullscreen-frame"),r.append(s);const d=document.createElement("div");d.classList.add("ghostkit-video-fullscreen-close"),d.innerHTML=n,k=document.createElement("div"),k.classList.add("ghostkit-video-fullscreen"),k.style.backgroundColor=u,k.style.backgroundImage=p,k.style.setProperty("--gkt-fullscreen-video--video__background",c||g),k.style.setProperty("--gkt-fullscreen-video__aspect-ratio-width",b),k.style.setProperty("--gkt-fullscreen-video__aspect-ratio-height",m),k.append(d),k.append(r),document.body.append(k),a.remove(),o(k),e.on(k,"click",(e=>{const o=e.target;(o.classList.contains("ghostkit-video-fullscreen")||o.classList.contains("ghostkit-video-fullscreen-close")||o.closest(".ghostkit-video-fullscreen-close"))&&(L.pause(),i.classList.add("ghostkit-video-fullscreen-closed"),t(k,{opacity:[1,0],display:"none"},{duration:.2}))}))})),s=1):s?L.play():(i.classList.add("ghostkit-video-loading"),L.getVideo((e=>{const t=e.parentNode,o=document.createElement("div");o.classList.add("ghostkit-video-frame"),o.append(e),i.append(o),t.remove()})),s=1))};e.on(i,"click",y),v||i.classList.contains("is-style-icon-only")||L.getImageURL((e=>{const t=document.createElement("img");t.setAttribute("src",e),t.setAttribute("alt",""),v=document.createElement("div"),v.classList.add("ghostkit-video-poster"),v.append(t),i.append(v)}));let h=!1;if(L.on("ready",(()=>{i.classList.remove("ghostkit-video-loading"),"fullscreen"===a?i.classList.contains("ghostkit-video-fullscreen-closed")||L.play():(i.classList.add("ghostkit-video-playing"),L.play())})),L.on("play",(()=>{f=!0})),L.on("pause",(()=>{f=!1,h=!0,"fullscreen"===a&&(l=0)})),"fullscreen"!==a&&(r||d)){if(!("IntersectionObserver"in window))return;const t={callback:e=>{e.forEach((e=>{i===e.target&&(!h&&!f&&r&&e.isIntersecting&&(l?L.play():i.click()),f&&d&&!e.isIntersecting&&L.pause())}))},options:{threshold:.6}};e.trigger(i,"prepare.videoObserver.gkt",{config:t}),new window.IntersectionObserver(t.callback,t.options).observe(i)}}e.trigger(i,"prepared.video.gkt")}))}))})();