trAvis - MANAGER
Edit File: plus-before-after.min.js
/*Before After*/var ba_Container,ba_obj,ba_sep_obj,ba_sep_Image,before_obj,after_obj,beforeImage,afterImage,ba_type,ba_sep_show,ba_show_mode,sep_Size,ba_ContainerId=0,changing_this=!1,Playing_this=!1,indSize=10,fpsPlay=60,TouchDevice=!1;function setba_Container(e){container=jQuery(e).closest(".pt_plus_before_after"),containerId=container.data("id"),hide_separator_image(container),ba_Container&&ba_ContainerId==containerId||(Playing_this&&(stop_animation(),ba_sep_show&&ba_sep_obj.show()),ba_Container=container,ba_ContainerId=containerId,ba_sep_obj=ba_Container.find(".before-after-sep"),ba_obj=ba_Container.find(".before-after-inner"),before_obj=ba_Container.find(".image-before"),after_obj=ba_Container.find(".image-after"),beforeImage=ba_Container.find(".image-before > img"),afterImage=ba_Container.find(".image-after > img"),ba_type=ba_Container.data("type"),ba_sep_show=!0,"false"==ba_Container.data("separate_switch")&&(ba_sep_show=!1),1==ba_sep_show?ba_sep_obj.show():ba_sep_obj.hide())}function play_animation(e,t,a,o,i,n){Playing_this&&(e+=t,"vertical"==ba_type?onMouseMove(a,o+e):onMouseMove(a+e,o),e<=i+1?setTimeout(play_animation,n,e,t,a,o,i,n):stop_animation())}function stop_animation(){Playing_this&&(changing_this=!(Playing_this=!1),ba_sep_obj.hide())}function onMouseMove(e,t,a){if(changing_this&&ba_sep_show&&ba_sep_obj.show(),!position_changing(e,t)){var o=jQuery("."+a);if(sep_Size=o.data("separate_width"),"horizontal"==ba_type){var i=jQuery("."+containerId).offset().left;pos=e-i,pos>=ba_obj.width()&&(pos=ba_obj.width()),jQuery("."+containerId+" .before-after-sep").css("left",pos-sep_Size/2),0!=ba_show_mode&&ba_sep_Image.css("left",pos),jQuery("."+containerId+" .before-after-image.image-before").width(pos),before_obj.find(".before_after_label.before_label_text").width()+50<pos?before_obj.find(".before_after_label.before_label_text").css("opacity","1"):before_obj.find(".before_after_label.before_label_text").css("opacity","0")}else if("vertical"==ba_type){i=jQuery("."+containerId).offset().top;pos=t-i,pos>=ba_obj.height()&&(pos=ba_obj.height()),jQuery("."+containerId+" .before-after-sep").css("top",pos-sep_Size/2),0!=ba_show_mode&&ba_sep_Image.css("top",pos),jQuery("."+containerId+" .before-after-image.image-before").height(pos),before_obj.find(".before_after_label.before_label_text").height()+50<pos?before_obj.find(".before_after_label.before_label_text").css("opacity","1"):before_obj.find(".before_after_label.before_label_text").css("opacity","0")}else if("cursor"==ba_type){pos=e-ba_Container.offset().left,pos>=ba_obj.width()&&(pos=ba_obj.width()),ba_sep_obj.css("left",pos-indSize/2),rat=pos/ba_obj.width(),beforeImage.css("opacity",1-rat);before_obj.find(".before_after_label.before_label_text");.3<1-rat?before_obj.find(".before_after_label.before_label_text").css("opacity","1"):before_obj.find(".before_after_label.before_label_text").css("opacity","0")}}}function size_Elements(){jQuery(".before-after-image > img").imgLoad(function(){if(img=jQuery(this),container=img.closest(".pt_plus_before_after"),container=container.data("id"),container=jQuery("."+container),style=container.data("type"),"show"!=style){if(img.css("min-width","none"),img.css("max-width","none"),sbsShrinked=!1,"yes"==container.data("responsive")){for(p=container.parent(),parentWidth=p.width();!p||0==parentWidth;)p=p.parent(),parentWidth=p.width();img.css("max-width")&&"none"!=img.css("max-width")||"yes"!=container.data("full_width")?img.css("max-width")&&"none"!=img.css("max-width")||img.css("max-width",img.width()):img.css("max-width",parentWidth),"yes"==container.data("full_width")?img.css("width",parentWidth):img.css("width",img.width())}if(container.data("width")&&img.css("width",container.data("width")),container.data("max-width")&&img.css("max-width",container.data("max-width")),initRatio=container.data("separate_position")/100,img.hasClass("image-before-wrap"))if(container.css("visibility","visible"),width=img.width(),height=img.height(),container.find(".before-after-image").width("auto"),container.find(".before-after-inner").width(width),container.find(".before-after-inner").height(height),container.find(".before-after-bottom-separate").width(width),container.width(width),"horizontal"==style?container.find(".image-before").width(img.width()*initRatio):"vertical"==style&&container.find(".image-before").height(img.height()*initRatio),separator=container.find(".before-after-sep"),"horizontal"==style)if("middle"==container.data("separator_style"))sep_Size=container.data("separate_width"),separator.width(sep_Size),separator.height(img.height()),sp=container.find(".image-before").width()-sep_Size/2,separator.css("left",sp),separator.css("cursor","ew-resize");else{sep_Size=container.data("separate_width"),separator.height(sep_Size),separator.width(15),separator.css("left",img.width()*initRatio+"px");var e=container.find(".image-before").height();separator.css("top",e),separator.css("cursor","ew-resize"),container.find(".before-after-bottom-separate").height(sep_Size),container.find(".before-after-bottom-separate").show()}else if("vertical"==style)"middle"==container.data("separator_style")&&(sep_Size=container.data("separate_width"),separator.height(sep_Size),separator.width(img.width()),sp=container.find(".image-before").height()-sep_Size/2,separator.css("top",sp),separator.css("cursor","ns-resize"));else if("cursor"==style&&1==container.data("separate_switch")){sep_Size=container.data("separate_width");e=container.find(".image-before").height();container.find(".before-after-bottom-separate").show()}}})}function hide_separator_image(e){ba_sep_Image=e.find(".before-after-sep-icon"),ba_show_mode=0,e.data("separate_image")&&(ba_show_mode=e.data("separate_image"))}function show_separator_image(){1==ba_show_mode&&ba_sep_Image.show()}function full_After(){w=ba_obj.width()-indSize,ba_sep_obj.css("left",w),beforeImage.css("opacity","0")}function zero_After(){ba_sep_obj.css("left",0),beforeImage.css("opacity","1")}function position_changing(e,t){if(!changing_this&&!Playing_this)return!1;if(Playing_this)return!1;if(aligned=!1,"horizontal"==ba_type){var a=jQuery("."+containerId).offset().left;e>=ba_obj.width()+a?(sep_Right(),aligned=!0):e<=a&&(sep_Left(),aligned=!0)}else if("vertical"==ba_type){a=jQuery("."+containerId).offset().top;t>=ba_obj.height()+a?(sep_Bottom(),aligned=!0):t<=a&&(sep_Top(),aligned=!0)}else"cursor"==ba_type&&(e+indSize/2>=ba_obj.width()+ba_Container.offset().left?(full_After(),aligned=!0):e-indSize/2<=ba_Container.offset().left&&(zero_After(),aligned=!0));return aligned&&"cursor"!=ba_type&&(Playing_this||ba_sep_obj.hide()),aligned}function sep_Right(){w=ba_obj.width(),ba_sep_obj.css("left",w-sep_Size/2),0!=ba_show_mode&&ba_sep_Image.css("left",w),before_obj.width(w)}function sep_Left(){ba_sep_obj.css("left",0),0!=ba_show_mode&&ba_sep_Image.css("left",0),before_obj.width(0)}function sep_Top(){ba_sep_obj.css("top",-sep_Size/2),0!=ba_show_mode&&ba_sep_Image.css("top",0),before_obj.height(0)}function sep_Bottom(){h=ba_obj.height(),ba_sep_obj.css("top",h-sep_Size/2),0!=ba_show_mode&&ba_sep_Image.css("top",h),before_obj.height(h)}function ba_init(){jQuery(".pt_plus_before_after").on("dragstart",function(e){e.preventDefault()}),contId=0,jQuery(".pt_plus_before_after").each(function(){var e=jQuery(this);t=e.data("id");var t=jQuery("."+t);t.css("visibility","hidden"),contId++,t.attr("data-before-after-id",contId),configType=t.data("type"),sep_Size=t.data("separate_width"),indSize=t.data("bottom-separator-size"),show=t.data("show"),show&&("cursor"==configType?(initRatio=t.data("separate_position"),t.find(".before-after-image").css("position","absolute"),t.find(".before-after-sep-icon").css("left",initRatio+"%"),t.find(".before-after-image").css("position","absolute"),t.find(".before-after-sep-icon").show(),t.find(".before-after-inner").on("mouseout",function(e){show_separator_image(),position_changing(e.pageX,e.pageY)})):(initRatio=t.data("separate_position"),"horizontal"==configType?t.find(".before-after-sep-icon").css("left",initRatio+"%"):"vertical"==configType&&t.find(".before-after-sep-icon").css("top",initRatio+"%"),t.find(".before-after-image").css("position","absolute"),t.find(".before-after-sep-icon").show(),t.find(".before-after-inner").on("mouseout",function(e){show_separator_image(),position_changing(e.pageX,e.pageY)})),"false"==t.data("separate_switch")&&(t.find(".before-after-bottom-separate").css("display","none"),t.find(".before-after-sep").css("display","none"),t.find(".before-after-sep-icon").css("display","none")),"show"!=configType&&(t.on("touchstart",function(e){setba_Container(this),changing_this=TouchDevice=!0}),t.on("touchend",function(){sep=jQuery(".pt_plus_before_after").find(".before-after-sep"),changing_this=!1,show_separator_image()}),t.on("touchcancel",function(){sep=jQuery(".pt_plus_before_after").find(".before-after-sep"),changing_this=!1,show_separator_image()})),"on"==t.data("click_hover_move")?(t.find(".before-after-inner, .before-after-bottom-separate").on("mouseover",function(e){setba_Container(this),Playing_this||(changing_this=!0,"horizontal"==ba_type?(pos=e.pageX-ba_Container.offset().left,jQuery(this).find(".separator").css("left",pos-sep_Size/2),jQuery(this).find(".image-before").width(pos),t.find(".before-after-inner").css("cursor","ew-resize")):"vertical"==ba_type?(pos=e.pageY-ba_Container.offset().top-sep_Size/2,jQuery(this).find(".separator").css("top",pos),jQuery(this).find(".image-before").height(pos),t.find(".before-after-inner").css("cursor","ns-resize")):"cursor"==ba_type&&(pos=e.pageX-ba_Container.offset().left,jQuery(this).find(".separator").css("left",pos-indSize/2)))}),t.find(".before-after-inner, .before-after-bottom-separate").on("mouseout",function(e){position_changing(e.pageX,e.pageY),changing_this=!1})):(t.find(".before-after-inner, .before-after-bottom-separate").on("mousedown",function(e){if(!TouchDevice){ba_sep_obj&&ba_sep_show&&ba_sep_obj.show(),setba_Container(this);var t=jQuery(this).parent(".pt_plus_before_after").data("id");onMouseMove(e.pageX,e.pageY,t)}}),t.find(".before-after-inner, .before-after-bottom-separate").on("mouseenter",function(e){ba_sep_obj&&ba_sep_show&&ba_sep_obj.show(),setba_Container(this),e.which||(changing_this=!1)}),t.find(".before-after-sep,.before-after-sep-icon").on("mousedown",function(e){TouchDevice||(setba_Container(this),changing_this=!0)}),t.find(".before-after-sep,.before-after-sep-icon").on("mouseover",function(e){setba_Container(this)}),t.find(".before-after-sep,.before-after-sep-icon").on("mouseup",function(){changing_this=!1}),t.find(".before-after-inner, .before-after-bottom-separate").on("mouseup",function(){changing_this=!1})),t.find(".before-after-inner").on("mousedown",function(e){TouchDevice||(setba_Container(this),stop_animation())}))}),size_Elements(),jQuery(".before-after-inner").on("mousemove",function(e){var t=jQuery(this).parent(".pt_plus_before_after").data("id");changing_this&&!Playing_this&&onMouseMove(e.pageX,e.pageY,t)}),jQuery(".before-after-bottom-separate").on("mousemove",function(e){var t=jQuery(this).parent(".pt_plus_before_after").data("id");changing_this&&!Playing_this&&onMouseMove(e.pageX,e.pageY,t)}),jQuery(".before-after-inner").on("touchmove",function(e){e.preventDefault(),touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];var t=jQuery(this).parent(".pt_plus_before_after").data("id");changing_this&&!Playing_this&&onMouseMove(touch.pageX,touch.pageY,t)}),jQuery(".before-after-bottom-separate").on("touchmove",function(e){e.preventDefault(),touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];var t=jQuery(this).parent(".pt_plus_before_after").data("id");changing_this&&!Playing_this&&onMouseMove(touch.pageX,touch.pageY,t)}),jQuery(window).on("resize",function(){size_Elements()})}!function(t){t.fn.imgLoad=function(e){return this.each(function(){e&&(this.complete?e.apply(this):t(this).on("load",function(){e.apply(this)}))})}}(jQuery),function(e){"use strict";function t(e,t){jQuery(document).ready(function(){ba_init()})}e(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/tp-before-after.default",t),elementorFrontend.isEditMode()&&elementorFrontend.hooks.addAction("frontend/element_ready/tp-before-after.default",t)})}(jQuery);