wp_back/wp-content/plugins/visual-portfolio/build/assets/js/items-style-fly.js
2024-05-20 15:37:46 +03:00

1 line
1.9 KiB
JavaScript

!function(){"use strict";var t={n:function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},d:function(e,n){for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.jQuery,n=t.n(e);const o=n()(window);function i(t,e,n,o){const i=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),s=(o.x-n.x)*(e.y-n.y)-(o.y-n.y)*(e.x-n.x),r=(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x),f=(e.x-t.x)*(o.y-t.y)-(e.y-t.y)*(o.x-t.x);return i*s<=0&&r*f<=0}n()(document).on("initEvents.vpf",((t,e)=>{if("vpf"!==t.namespace||"fly"!==e.options.itemsStyle)return;const s=`.vpf-uid-${e.uid}`;let r={};o.on(`mousemove${s}`,(t=>{r={x:t.clientX,y:t.clientY}})),e.$item.on(`mouseenter${s} mouseleave${s}`,".vp-portfolio__item",(function(t){const e=n()(this),o=e[0].getBoundingClientRect(),s=e.find(".vp-portfolio__item-overlay"),f="mouseenter"===t.type;let y="0%",a="0%";const l={x:t.clientX,y:t.clientY};let u=i({x:o.left,y:o.top},{x:o.left+o.width,y:o.top},l,r),c=i({x:o.left,y:o.top+o.height},{x:o.left+o.width,y:o.top+o.height},l,r),p=i({x:o.left,y:o.top},{x:o.left,y:o.top+o.height},l,r),x=i({x:o.left+o.width,y:o.top},{x:o.left+o.width,y:o.top+o.height},l,r);if(!(u||c||p||x)){const t=(o.width/2-l.x+o.left)/(o.width/2),e=(o.height/2-l.y+o.top)/(o.height/2);Math.abs(t)>Math.abs(e)?t>0?p=!0:x=!0:e>0?u=!0:c=!0}u?a="-100.1%":c?a="100.1%":p?y="-100.1%":x&&(y="100.1%"),f&&(s.css({transition:"none",transform:`translateX(${y}) translateY(${a}) translateZ(0)`}),s[0].offsetHeight),s.css({transition:".2s transform ease-in-out",transform:`translateX(${f?"0%":y}) translateY(${f?"0%":a}) translateZ(0)`})}))})),n()(document).on("destroyEvents.vpf",((t,e)=>{if("vpf"!==t.namespace||"fly"!==e.options.itemsStyle)return;const n=`.vpf-uid-${e.uid}`;o.off(`mousemove${n}`),e.$item.off(`mouseenter${n} mouseleave${n}`)}))}();