
/*
	* 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:"1.1",requiredLSVersion:"8.1.1",authorName:"Kreatura",releaseDate:"2025. 12. 04."},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=d.layerData;if(c.$effectLayers.is(e)){var g=d.layerData.elements.$innerWrapper.children();g.wrapAll("<ls-liquify-wrapper style=\"display:flex;\"></ls-liquify-wrapper>");var h,i=e.data(c.pluginData.key);f.liquify={},i.ease=b.functions.convert.easing(i.ease),i.easeOut=b.functions.convert.easing(i.easeOut),i.duration/=1e3,i.durationOut/=1e3;var j=e;g.filter(".ls-layer-link").length&&(j=g.filter(".ls-layer-link")),j.on("mouseenter."+c.pluginData.key,function(c){h=this.getBoundingClientRect(),i.scaleMaxY=i.scaleMaxY||1+h.width/h.height*(i.scaleMaxX-1),f.liquify.enter={clientX:c.clientX,clientY:c.clientY,rect:h,x:Math.min(Math.max(c.clientX-h.left,0),h.width),y:Math.min(Math.max(c.clientY-h.top,0),h.height)},"tethered"!==i.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){h=this.getBoundingClientRect();var d=f.liquify.enter,e=c.clientX-d.clientX,g=c.clientY-d.clientY,j=Math.abs(e)/(d.rect.width*i.scaleMaxX/100),k=Math.abs(g)/(d.rect.height*i.scaleMaxY/100);j=Math.round(100*j)/100,k=Math.round(100*k)/100;var l=1+(i.scaleMaxX-1)*(j/100),m=1+(i.scaleMaxY-1)*(Math.abs(k)/100),n=i.skewMaxX*(j/100)*(k/100),o=i.rotationMax*(j/100),p=-i.rotationMax*(k/100);n*=(0>e?1:-1)*(0>g?1:-1),o*=0>e?1:-1,p*=0>g?1:-1,l=Math.max(l,1),m=Math.max(m,1),i.intensity=Math.max(i.intensity,.1),l=1+(l-1)*i.intensity,m=1+(m-1)*i.intensity,n*=i.intensity,p*=i.intensity,o*=i.intensity,l=Math.min(l,i.scaleMaxX),m=Math.min(m,i.scaleMaxY),n=Math.min(Math.max(n,-i.skewMaxX),i.skewMaxX),p=Math.min(Math.max(p,-i.rotationMax),i.rotationMax),o=Math.min(Math.max(o,-i.rotationMax),i.rotationMax),"x"===i.axes?(m=1,p=0):"y"===i.axes&&(l=1,o=0),b.gsap.TweenMax.to(a(this).parent()[0],i.duration,{scaleX:l,scaleY:m,skewX:n,rotationX:p,rotationY:o,ease:i.ease})}).on("mouseleave."+c.pluginData.key,function(c){var d=f.liquify.enter,e=this,g=a(e),h=g.parent(),j=h[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"!==i.releaseEffect){var m={trx:d.x,try:d.y},n={trx:k,try:l},o=1e4,p=0,q=1e4,r=0;switch(i.releaseEffect){case"natural":f.timelines._liquifyLeave.to(m,i.durationOut/2,{trx:d.rect.width/2,try:d.rect.height/2,ease:b.gsap.Quart.easeOut,onUpdate:function(){h.css("transformOrigin",this.target.trx+"px "+this.target.try+"px")}},0);break;case"bouncy":f.timelines._liquifyLeave.to(m,i.durationOut/3,{trx:n.trx,try:n.try,ease:b.gsap.Quart.easeOut,onUpdate:function(){h.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,i.durationOut/2,{trx:d.rect.width/2,try:d.rect.height/2,ease:b.gsap.Quart.easeOut,onUpdate:function(){h.css("transformOrigin",this.target.trx+"px "+this.target.try+"px")}},i.durationOut/3);}}f.timelines._liquifyLeave.to(j,i.durationOut,{scaleX:1,scaleY:1,skewX:0,rotationX:0,rotationY:0,ease:i.easeOut},0),f.timelines._liquifyLeave.play()})}})}}})(jQuery,void 0);