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 / extend / effects / frontend.js

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

1 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";const t={x:0,y:0,opacity:1,scale:1,rotate:0,transition:{type:"spring",stiffness:300,damping:35,mass:2,delay:0}},{GHOSTKIT:{events:e,instance:n},Motion:{animate:a,spring:r,inView:s}}=window,o=window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.on(document,"init.blocks.gkt",(()=>{document.querySelectorAll("[data-gkt-effects]").forEach((function(i){if(o)return void i.removeAttribute("data-gkt-effects");const c=i.getAttribute("data-gkt-effects");let g;try{g=JSON.parse(c)}catch(t){g=!1}if(i.removeAttribute("data-gkt-effects"),!g)return;if(e.trigger(i,"prepare.effects.gkt",{data:g}),n.set(i,"effects",g),!g?.reveal)return;const l={...t,...g.reveal};e.trigger(i,"prepare.effects.reveal.gkt",{config:l});const f=s(i,(()=>{i.classList.remove("ghostkit-effects-reveal");const t={};"easing"===l?.transition?.type?(t.type="tween",t.duration=l.transition.duration,t.delay=l.transition.delay,t.ease=l.transition.easing):"spring"===l?.transition?.type&&(t.type=r,t.delay=l.transition.delay,t.stiffness=l.transition.stiffness,t.damping=l.transition.damping,t.mass=l.transition.mass);const n={};1!==l.opacity&&(n.opacity=[l.opacity,1]),0!==l.x&&(n.x=[l.x,0]),0!==l.y&&(n.y=[l.y,0]),1!==l.scale&&(n.scale=[l.scale,1]),0!==l.rotate&&(n.rotate=[l.rotate,0]);const s={config:l,keyframes:n,options:t,stopInView:f,leaveCallback:()=>{}};return e.trigger(i,"show.effects.reveal.gkt",s),s.stopInView(),a(i,n,t).then((()=>{e.trigger(i,"showed.effects.reveal.gkt",s)})),s.leaveCallback}));e.trigger(i,"prepared.effects.reveal.gkt",{config:l})}))})),e.on(document,"init.blocks.gkt",(()=>{document.querySelectorAll(".ghostkit-count-up:not(.ghostkit-count-up-ready)").forEach((t=>{if(t.classList.add("ghostkit-count-up-ready"),o)return;const n=t.classList.contains("ghostkit-progress-bar"),r=n?t.closest(".ghostkit-progress"):null,i=parseFloat(t.getAttribute("data-count-from"))||0,c=parseFloat(n?t.getAttribute("aria-valuenow"):t.textContent)||0;let g,l,f=0,d="";n||(d=t.textContent.replace(c,"${val}")),/\${val}/.test(d)||(d="${val}"),n?(g=r?.querySelector(".ghostkit-progress-bar-count"),g&&(l=g.querySelector(":scope > div > span:nth-child(2)"),g.style.width="0%",l.textContent="0"),t.style.width="0%"):(t.textContent=d.replace("${val}",i),f=Math.max((`${i}`.split(".")?.[1]||"").length,(`${c}`.split(".")?.[1]||"").length));const p={from:i,to:c,duration:1,easing:[.6,0,.3,1],cb(e){const a=(c-i)*e+i;n?(t.style.width=`${a}%`,g&&(g.style.width=`${a}%`),l&&(l.textContent=Math.ceil(a))):t.textContent=d.replace("${val}",function(t,e=1){const n=10**e;return Math.round(t*n)/n}(a,f))}};e.trigger(t,"prepare.counter.gkt",{config:p});const u=s(r||t,(()=>{u(),e.trigger(t,"count.counter.gkt",{config:p}),a(0,1,{duration:p.duration,ease:p.easing,onUpdate:t=>{p.cb(t)}}).then((()=>{e.trigger(t,"counted.counter.gkt",{config:p})}))}),{margin:"-50px"})}))}))})();