
/*
	* LayerSlider Add-On: Liquify Layer Effect
	*
	* (c) 2011-2025 George Krupa, John Gera & Kreatura Media
	*
	* LayerSlider home:		https://layerslider.com/
	* Licensing:			https://layerslider.com/licensing/
*/



;(function(a){window._layerSlider.plugins.liquify=function(b){var c=this,d=window._lsData;c.pluginData={name:"Liquify Add-On for LayerSlider",key:"liquify",version:"0.9",requiredLSVersion:"8.0.0",authorName:"Kreatura",releaseDate:"2025. 10. 30."},c.pluginDefaults={eventNamespace:"li"},c.state={initialized:!1},c.init=function(){c.extendLayerSlider(),c.state.initialized=!0},c.settings={axes:"both",scaleMaxX:1.3,scaleMaxY:0,skewMaxX:10,rotationMax:10,duration:500,ease:"easeOutQuart",durationOut:1500,easeOut:"easeOutElastic",releaseEffect:"tethered",intensity:1},c.extendLayerSlider=function(){b.plugins.addFunction("initSlidesBefore",c.pluginData.key,function(){c.$effectLayers=b.plugins.getLayersByEffect(c.pluginData.key),c.$effectLayers.each(function(b,d){a(d).data(c.pluginData.key,a.extend(!0,{},c.settings,a(d).data(c.pluginData.key)))})}),b.plugins.addFunction("wrapLayerEnd",c.pluginData.key,function(d){var e=d.$layer,f=e.data(b.defaults.init.dataKey);if(c.$effectLayers.is(e)){e.wrap("<ls-liquify-wrapper style=\"display:flex;\"></ls-liquify-wrapper>");var g,h=e.data(c.pluginData.key);f.liquify={},h.ease=b.functions.convert.easing(h.ease),h.easeOut=b.functions.convert.easing(h.easeOut),h.duration/=1e3,h.durationOut/=1e3,e.on("mouseenter."+c.pluginData.key,function(c){g=this.getBoundingClientRect(),h.scaleMaxY=h.scaleMaxY||1+g.width/g.height*(h.scaleMaxX-1),f.liquify.enter={clientX:c.clientX,clientY:c.clientY,rect:g,x:Math.min(Math.max(c.clientX-g.left,0),g.width),y:Math.min(Math.max(c.clientY-g.top,0),g.height)},"tethered"!==h.releaseEffect&&b.timelines.to([f.timelines,"_liquifyLeave",1,!0,!0,!0]),b.gsap.TweenMax.set(a(this).parent()[0],{transformOrigin:f.liquify.enter.x+"px "+f.liquify.enter.y+"px",transformPerspective:1e3})}).on("mousemove."+c.pluginData.key,function(c){g=this.getBoundingClientRect();var d=f.liquify.enter,e=c.clientX-d.clientX,i=c.clientY-d.clientY,j=Math.abs(e)/(d.rect.width*h.scaleMaxX/100),k=Math.abs(i)/(d.rect.height*h.scaleMaxY/100);j=Math.round(100*j)/100,k=Math.round(100*k)/100;var l=1+(h.scaleMaxX-1)*(j/100),m=1+(h.scaleMaxY-1)*(Math.abs(k)/100),n=h.skewMaxX*(j/100)*(k/100),o=h.rotationMax*(j/100),p=-h.rotationMax*(k/100);n*=(0>e?1:-1)*(0>i?1:-1),o*=0>e?1:-1,p*=0>i?1:-1,l=Math.max(l,1),m=Math.max(m,1),h.intensity=Math.max(h.intensity,.1),l=1+(l-1)*h.intensity,m=1+(m-1)*h.intensity,n*=h.intensity,p*=h.intensity,o*=h.intensity,l=Math.min(l,h.scaleMaxX),m=Math.min(m,h.scaleMaxY),n=Math.min(Math.max(n,-h.skewMaxX),h.skewMaxX),p=Math.min(Math.max(p,-h.rotationMax),h.rotationMax),o=Math.min(Math.max(o,-h.rotationMax),h.rotationMax),"x"===h.axes?(m=1,p=0):"y"===h.axes&&(l=1,o=0),b.gsap.TweenMax.to(a(this).parent()[0],h.duration,{scaleX:l,scaleY:m,skewX:n,rotationX:p,rotationY:o,ease:h.ease})}).on("mouseleave."+c.pluginData.key,function(c){var d=f.liquify.enter,e=this,g=a(e),i=g.parent(),j=i[0],k=c.clientX-d.clientX+d.x,l=c.clientY-d.clientY+d.y;if(f.timelines._liquifyLeave=new b.gsap.TimelineMax({paused:!0}),"tethered"!==h.releaseEffect){var m={trx:d.x,try:d.y},n={trx:k,try:l},o=1e4,p=0,q=1e4,r=0;switch(h.releaseEffect){case"natural":f.timelines._liquifyLeave.to(m,h.durationOut/2,{trx:d.rect.width/2,try:d.rect.height/2,ease:b.gsap.Quart.easeOut,onUpdate:function(){i.css("transformOrigin",this.target.trx+"px "+this.target.try+"px")}},0);break;case"bouncy":f.timelines._liquifyLeave.to(m,h.durationOut/3,{trx:n.trx,try:n.try,ease:b.gsap.Quart.easeOut,onUpdate:function(){i.css("transformOrigin",this.target.trx+"px "+this.target.try+"px");var a=e.getBoundingClientRect();o=Math.min(o,a.left),p=Math.max(p,a.right),q=Math.min(q,a.top),r=Math.max(r,a.bottom)}},0),f.timelines._liquifyLeave.to(n,h.durationOut/2,{trx:d.rect.width/2,try:d.rect.height/2,ease:b.gsap.Quart.easeOut,onUpdate:function(){i.css("transformOrigin",this.target.trx+"px "+this.target.try+"px")}},h.durationOut/3);}}f.timelines._liquifyLeave.to(j,h.durationOut,{scaleX:1,scaleY:1,skewX:0,rotationX:0,rotationY:0,ease:h.easeOut},0),f.timelines._liquifyLeave.play()})}})}}})(jQuery,void 0);