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 / image-compare / frontend.js

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

1 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{const{GHOSTKIT:{events:t}}=window;let e=!1,o=!1,i="",a=!1,r=0,n=0;function c(){if(e&&o){const a=o.getBoundingClientRect();let c=0;c="vertical"===i?Math.max(0,Math.min(1,(n-a.top)/a.height)):Math.max(0,Math.min(1,(r-a.left)/a.width));const s=Math.round(1e4*c)/100;e.style.setProperty("--gkt-image-compare__position",`${s}%`),t.trigger(e,"move.imageCompare.gkt",{originalEvent:{clientX:r,clientY:n}})}}function s(t){e=t,o=t.querySelector(".ghostkit-image-compare-images"),i=t.classList.contains("ghostkit-image-compare-vertical")?"vertical":"horizontal"}function g(){c(),e.style.removeProperty("--gkt-image-compare__transition-duration"),e=!1,o=!1,a=!1}t.on(document,"mousedown touchstart",".ghostkit-image-compare:not(.ghostkit-image-compare-trigger-hover)",(t=>{t.targetTouches&&!t.target.classList.contains("ghostkit-image-compare-images-divider")||(t.targetTouches||t.preventDefault(),s(t.delegateTarget))})),t.on(document,"mouseover touchstart",".ghostkit-image-compare-trigger-hover",(t=>{e||t.targetTouches&&!t.target.classList.contains("ghostkit-image-compare-images-divider")||(t.targetTouches||t.preventDefault(),s(t.delegateTarget))})),t.on(document,"mouseout touchend",".ghostkit-image-compare-trigger-hover",(t=>{e&&(t.targetTouches||(r=t.clientX,n=t.clientY),g())})),t.on(document,"mouseup touchend",(t=>{e&&(t.targetTouches||(r=t.clientX,n=t.clientY),g())})),t.on(document,"mousemove touchmove",(t=>{e&&(t.targetTouches||t.preventDefault(),r=t.targetTouches?.[0].clientX||t.clientX,n=t.targetTouches?.[0].clientY||t.clientY,a||(e.style.setProperty("--gkt-image-compare__transition-duration","0s"),a=!0),c())})),window.addEventListener("touchstart",(function(t){e&&t.target.classList.contains("ghostkit-image-compare-images-divider")&&t.preventDefault()}),{passive:!1})})();