PageSourceSearch

https://sppts.org/g/s3/lp/lpc.v4/plugins/lightgallery/v.2.7.2/plugins/lg-zoom.min.js

js sppts.org collected 2026-09-30 22:12:35 UTC 17,109 bytes, 34 lines download raw bytes

1'use strict';var __assign=function(){__assign=Object.assign||function(h){for(var a,b=1,c=arguments.length;b<c;b++){a=arguments[b];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(h[e]=a[e])}return h};return __assign.apply(this,arguments)},zoomSettings={scale:1,zoom:!0,infiniteZoom:!0,actualSize:!0,showZoomInOutIcons:!1,actualSizeIcons:{zoomIn:"lpc-lg-zoom-in",zoomOut:"lpc-lg-zoom-out"},enableZoomAfter:300,zoomPluginStrings:{zoomIn:"Zoom in",zoomOut:"Zoom out",viewActualSize:"View actual size"}},
2lGEvents={afterAppendSlide:"lgAfterAppendSlide",init:"lgInit",hasVideo:"lgHasVideo",containerResize:"lgContainerResize",updateSlides:"lgUpdateSlides",afterAppendSubHtml:"lgAfterAppendSubHtml",beforeOpen:"lgBeforeOpen",afterOpen:"lgAfterOpen",slideItemLoad:"lgSlideItemLoad",beforeSlide:"lgBeforeSlide",afterSlide:"lgAfterSlide",posterClick:"lgPosterClick",dragStart:"lgDragStart",dragMove:"lgDragMove",dragEnd:"lgDragEnd",beforeNextSlide:"lgBeforeNextSlide",beforePrevSlide:"lgBeforePrevSlide",beforeClose:"lgBeforeClose",
3afterClose:"lgAfterClose",rotateLeft:"lgRotateLeft",rotateRight:"lgRotateRight",flipHorizontal:"lgFlipHorizontal",flipVertical:"lgFlipVertical",autoplay:"lgAutoplay",autoplayStart:"lgAutoplayStart",autoplayStop:"lgAutoplayStop"},ZOOM_TRANSITION_DURATION=500,Zoom=function(){function h(a,b){this.core=a;this.$LG=b;this.settings=__assign(__assign({},zoomSettings),this.core.settings);return this}h.prototype.buildTemplates=function(){var a=this.settings.showZoomInOutIcons?'<button id="'+this.core.getIdName("lpc-lg-zoom-in")+
4'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomIn+'" class="lpc-lg-zoom-in lpc-lg-icon"></button><button id="'+this.core.getIdName("lpc-lg-zoom-out")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomIn+'" class="lpc-lg-zoom-out lpc-lg-icon"></button>':"";this.settings.actualSize&&(a+='<button id="'+this.core.getIdName("lpc-lg-actual-size")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.viewActualSize+'" class="'+this.settings.actualSizeIcons.zoomIn+
5' lpc-lg-icon"></button>');this.core.outer.addClass("lpc-lg-use-transition-for-zoom");this.core.$toolbar.first().append(a)};h.prototype.enableZoom=function(a){var b=this,c=this.settings.enableZoomAfter+a.detail.delay;this.$LG("body").first().hasClass("lpc-lg-from-hash")&&a.detail.delay?c=0:this.$LG("body").first().removeClass("lpc-lg-from-hash");this.zoomableTimeout=setTimeout(function(){b.isImageSlide(b.core.index)&&(b.core.getSlideItem(a.detail.index).addClass("lpc-lg-zoomable"),a.detail.index===
6b.core.index&&b.setZoomEssentials())},c+30)};h.prototype.enableZoomOnSlideItemLoad=function(){this.core.LGel.on(lGEvents.slideItemLoad+".zoom",this.enableZoom.bind(this))};h.prototype.getDragCords=function(a){return{x:a.pageX,y:a.pageY}};h.prototype.getSwipeCords=function(a){return{x:a.touches[0].pageX,y:a.touches[0].pageY}};h.prototype.getDragAllowedAxises=function(a,b){var c=this.core.getSlideItem(this.core.index).find(".lpc-lg-image").first().get(),e=c.getBoundingClientRect();if(a){var f=c.offsetHeight*
7a;a*=c.offsetWidth}else b?(f=e.height+b*e.height,a=e.width+b*e.width):(f=e.height,a=e.width);return{allowX:a>this.containerRect.width,allowY:f>this.containerRect.height}};h.prototype.setZoomEssentials=function(){this.containerRect=this.core.$content.get().getBoundingClientRect()};h.prototype.zoomImage=function(a,b,c,e){if(!(0>=Math.abs(b))){var f=this.containerRect.width/2+this.containerRect.left,d=this.containerRect.height/2+this.containerRect.top+this.scrollTop;1===a&&(this.positionChanged=!1);
8var g=this.getDragAllowedAxises(0,b),n=g.allowY;g=g.allowX;if(this.positionChanged){var l=this.left/(this.scale-b);var m=this.top/(this.scale-b);this.pageX=f-l;this.pageY=d-m;this.positionChanged=!1}l=this.getPossibleSwipeDragCords(b);f-=this.pageX;d-=this.pageY;1<a-b?(m=(a-b)/Math.abs(b),f=(0>b?-f:f)+this.left*(m+(0>b?-1:1)),d=(0>b?-d:d)+this.top*(m+(0>b?-1:1)),b=f/m,d/=m):(m=(a-b)*b,b=f*m,d*=m);c&&(g?this.isBeyondPossibleLeft(b,l.minX)?b=l.minX:this.isBeyondPossibleRight(b,l.maxX)&&(b=l.maxX):1<
9a&&(b<l.minX?b=l.minX:b>l.maxX&&(b=l.maxX)),n?this.isBeyondPossibleTop(d,l.minY)?d=l.minY:this.isBeyondPossibleBottom(d,l.maxY)&&(d=l.maxY):1<a&&(d<l.minY?d=l.minY:d>l.maxY&&(d=l.maxY)));this.setZoomStyles({x:b,y:d,scale:a});this.left=b;this.top=d;e&&this.setZoomImageSize()}};
9h.prototype.resetImageTranslate=function(a){if(this.isImageSlide(a)){var b=this.core.getSlideItem(a).find(".lpc-lg-image").first();this.imageReset=!1;b.removeClass("reset-transition reset-transition-y reset-transition-x");this.core.outer.removeClass("lpc-lg-actual-size");
10b.css("width","auto").css("height","auto");setTimeout(function(){b.removeClass("no-transition")},10)}};h.prototype.setZoomImageSize=function(){var a=this,b=this.core.getSlideItem(this.core.index).find(".lpc-lg-image").first();setTimeout(function(){var c=a.getCurrentImageActualSizeScale();a.scale>=c&&(b.addClass("no-transition"),a.imageReset=!0)},ZOOM_TRANSITION_DURATION);setTimeout(function(){var c=a.getCurrentImageActualSizeScale();a.scale>=c&&(c=a.getDragAllowedAxises(a.scale),b.css("width",b.get().naturalWidth+
11"px").css("height",b.get().naturalHeight+"px"),a.core.outer.addClass("lpc-lg-actual-size"),c.allowX&&c.allowY?b.addClass("reset-transition"):c.allowX&&!c.allowY?b.addClass("reset-transition-x"):!c.allowX&&c.allowY&&b.addClass("reset-transition-y"))},ZOOM_TRANSITION_DURATION+50)};h.prototype.setZoomStyles=function(a){var b=this.core.getSlideItem(this.core.index).find(".lpc-lg-img-wrap").first(),c=this.core.getSlideItem(this.core.index).find(".lpc-lg-image").first(),e=this.core.outer.find(".lpc-lg-current .lpc-lg-dummy-img").first();
12this.scale=a.scale;c.css("transform","scale3d("+a.scale+", "+a.scale+", 1)");e.css("transform","scale3d("+a.scale+", "+a.scale+", 1)");b.css("transform","translate3d("+a.x+"px, "+a.y+"px, 0)")};h.prototype.setActualSize=function(a,b){var c=this;if(!this.zoomInProgress){this.zoomInProgress=!0;var e=this.core.galleryItems[this.core.index];this.resetImageTranslate(a);setTimeout(function(){if(e.src&&!c.core.outer.hasClass("lpc-lg-first-slide-loading")){var f=c.getCurrentImageActualSizeScale(),d=c.scale;
13c.core.outer.hasClass("lpc-lg-zoomed")?c.scale=1:c.scale=c.getScale(f);c.setPageCords(b);c.beginZoom(c.scale);c.zoomImage(c.scale,c.scale-d,!0,!0)}},50);setTimeout(function(){c.core.outer.removeClass("lpc-lg-grabbing").addClass("lpc-lg-grab")},60);setTimeout(function(){c.zoomInProgress=!1},ZOOM_TRANSITION_DURATION+110)}};h.prototype.getNaturalWidth=function(a){var b=this.core.getSlideItem(a).find(".lpc-lg-image").first();return(a=this.core.galleryItems[a].width)?parseFloat(a):b.get().naturalWidth};
14h.prototype.getActualSizeScale=function(a,b){return a>=b?a/b||2:1};h.prototype.getCurrentImageActualSizeScale=function(){var a=this.core.getSlideItem(this.core.index).find(".lpc-lg-image").first().get().offsetWidth,b=this.getNaturalWidth(this.core.index)||a;return this.getActualSizeScale(b,a)};h.prototype.getPageCords=function(a){var b={};a?(b.x=a.pageX||a.touches[0].pageX,b.y=a.pageY||a.touches[0].pageY):(a=this.core.$content.get().getBoundingClientRect(),b.x=a.width/2+a.left,b.y=a.height/2+this.scrollTop+
15a.top);return b};h.prototype.setPageCords=function(a){a=this.getPageCords(a);this.pageX=a.x;this.pageY=a.y};h.prototype.manageActualPixelClassNames=function(){this.core.getElementById("lpc-lg-actual-size").removeClass(this.settings.actualSizeIcons.zoomIn).addClass(this.settings.actualSizeIcons.zoomOut)};h.prototype.beginZoom=function(a){this.core.outer.removeClass("lpc-lg-zoom-drag-transition lpc-lg-zoom-dragging");1<a?(this.core.outer.addClass("lpc-lg-zoomed"),this.manageActualPixelClassNames()):
16this.resetZoom();return 1<a};h.prototype.getScale=function(a){var b=this.getCurrentImageActualSizeScale();1>a?a=1:a>b&&(a=b);return a};h.prototype.init=function(){var a=this;if(this.settings.zoom){this.buildTemplates();this.enableZoomOnSlideItemLoad();var b=null;this.core.outer.on("dblclick.lg",function(c){a.$LG(c.target).hasClass("lpc-lg-image")&&a.setActualSize(a.core.index,c)});this.core.outer.on("touchstart.lg",function(c){var e=a.$LG(c.target);1===c.touches.length&&e.hasClass("lpc-lg-image")&&
17(b?(clearTimeout(b),b=null,c.preventDefault(),a.setActualSize(a.core.index,c)):b=setTimeout(function(){b=null},300))});this.core.LGel.on(lGEvents.containerResize+".zoom "+lGEvents.rotateRight+".zoom "+lGEvents.rotateLeft+".zoom "+lGEvents.flipHorizontal+".zoom "+lGEvents.flipVertical+".zoom",function(){if(a.core.lgOpened&&a.isImageSlide(a.core.index)&&!a.core.touchAction){var c=a.core.getSlideItem(a.core.index).find(".lpc-lg-img-wrap").first();a.top=0;a.left=0;a.setZoomEssentials();a.setZoomSwipeStyles(c,
18{x:0,y:0});a.positionChanged=!0}});this.$LG(window).on("scroll.lg.zoom.global"+this.core.lgId,function(){a.core.lgOpened&&(a.scrollTop=a.$LG(window).scrollTop())});this.core.getElementById("lpc-lg-zoom-out").on("click.lg",function(){if(a.isImageSlide(a.core.index)){var c=0;a.imageReset&&(a.resetImageTranslate(a.core.index),c=50);setTimeout(function(){var e=a.scale-a.settings.scale;1>e&&(e=1);a.beginZoom(e);a.zoomImage(e,-a.settings.scale,!0,!a.settings.infiniteZoom)},c)}});this.core.getElementById("lpc-lg-zoom-in").on("click.lg",
19function(){a.zoomIn()});this.core.getElementById("lpc-lg-actual-size").on("click.lg",function(){a.setActualSize(a.core.index)});this.core.LGel.on(lGEvents.beforeOpen+".zoom",function(){a.core.outer.find(".lpc-lg-item").removeClass("lpc-lg-zoomable")});this.core.LGel.on(lGEvents.afterOpen+".zoom",function(){a.scrollTop=a.$LG(window).scrollTop();a.pageX=a.core.outer.width()/2;
19a.pageY=a.core.outer.height()/2+a.scrollTop;a.scale=1});this.core.LGel.on(lGEvents.afterSlide+".zoom",function(c){c=c.detail.prevIndex;
20a.scale=1;a.positionChanged=!1;a.zoomInProgress=!1;a.resetZoom(c);a.resetImageTranslate(c);a.isImageSlide(a.core.index)&&a.setZoomEssentials()});this.zoomDrag();this.pinchZoom();this.zoomSwipe();this.zoomInProgress=this.positionChanged=this.zoomableTimeout=!1}};h.prototype.zoomIn=function(){if(this.isImageSlide(this.core.index)){var a=this.scale+this.settings.scale;this.settings.infiniteZoom||(a=this.getScale(a));this.beginZoom(a);this.zoomImage(a,Math.min(this.settings.scale,a-this.scale),!0,!this.settings.infiniteZoom)}};
21h.prototype.resetZoom=function(a){this.core.outer.removeClass("lpc-lg-zoomed lpc-lg-zoom-drag-transition");var b=this.core.getElementById("lpc-lg-actual-size");a=this.core.getSlideItem(void 0!==a?a:this.core.index);b.removeClass(this.settings.actualSizeIcons.zoomOut).addClass(this.settings.actualSizeIcons.zoomIn);a.find(".lpc-lg-img-wrap").first().removeAttr("style");a.find(".lpc-lg-image").first().removeAttr("style");this.scale=1;this.top=this.left=0;this.setPageCords()};h.prototype.getTouchDistance=
22function(a){return Math.sqrt((a.touches[0].pageX-a.touches[1].pageX)*(a.touches[0].pageX-a.touches[1].pageX)+(a.touches[0].pageY-a.touches[1].pageY)*(a.touches[0].pageY-a.touches[1].pageY))};h.prototype.pinchZoom=function(){var a=this,b=0,c=!1,e=1,f=0,d=this.core.getSlideItem(this.core.index);this.core.outer.on("touchstart.lg",function(g){d=a.core.getSlideItem(a.core.index);a.isImageSlide(a.core.index)&&2===g.touches.length&&(g.preventDefault(),a.core.outer.hasClass("lpc-lg-first-slide-loading")||
23(e=a.scale||1,a.core.outer.removeClass("lpc-lg-zoom-drag-transition lpc-lg-zoom-dragging"),a.setPageCords(g),a.resetImageTranslate(a.core.index),a.core.touchAction="pinch",b=a.getTouchDistance(g)))});this.core.$inner.on("touchmove.lg",function(g){2===g.touches.length&&"pinch"===a.core.touchAction&&(a.$LG(g.target).hasClass("lpc-lg-item")||d.get().contains(g.target))&&(g.preventDefault(),g=a.getTouchDistance(g),g=b-g,!c&&5<Math.abs(g)&&(c=!0),c&&(f=a.scale,a.scale=Math.round(100*(Math.max(1,e+.02*
24-g)+Number.EPSILON))/100,a.zoomImage(a.scale,Math.round(100*(a.scale-f+Number.EPSILON))/100,!1,!1)))});this.core.$inner.on("touchend.lg",function(g){if("pinch"===a.core.touchAction&&(a.$LG(g.target).hasClass("lpc-lg-item")||d.get().contains(g.target))){c=!1;b=0;if(1>=a.scale)a.resetZoom();else{g=a.getCurrentImageActualSizeScale();if(a.scale>=g){var n=g-a.scale;0===n&&(n=.01);a.zoomImage(g,n,!1,!0)}a.manageActualPixelClassNames();a.core.outer.addClass("lpc-lg-zoomed")}a.core.touchAction=void 0}})};
25h.prototype.touchendZoom=function(a,b,c,e,f){var d=b.x-a.x;a=b.y-a.y;b=Math.abs(d)/f+1;f=Math.abs(a)/f+1;2<b&&(b+=1);2<f&&(f+=1);d*=b;a*=f;f=this.core.getSlideItem(this.core.index).find(".lpc-lg-img-wrap").first();b={};b.x=this.left+d;b.y=this.top+a;var g=this.getPossibleSwipeDragCords();if(15<Math.abs(d)||15<Math.abs(a))e&&(this.isBeyondPossibleTop(b.y,g.minY)?b.y=g.minY:this.isBeyondPossibleBottom(b.y,g.maxY)&&(b.y=g.maxY)),c&&(this.isBeyondPossibleLeft(b.x,g.minX)?b.x=g.minX:this.isBeyondPossibleRight(b.x,
26g.maxX)&&(b.x=g.maxX)),e?this.top=b.y:b.y=this.top,c?this.left=b.x:b.x=this.left,this.setZoomSwipeStyles(f,b),this.positionChanged=!0};h.prototype.getZoomSwipeCords=function(a,b,c,e,f){var d={};e?(d.y=this.top+(b.y-a.y),this.isBeyondPossibleTop(d.y,f.minY)?d.y=f.minY-(f.minY-d.y)/6:this.isBeyondPossibleBottom(d.y,f.maxY)&&(d.y=f.maxY+(d.y-f.maxY)/6)):d.y=this.top;c?(d.x=this.left+(b.x-a.x),this.isBeyondPossibleLeft(d.x,f.minX)?d.x=f.minX-(f.minX-d.x)/6:this.isBeyondPossibleRight(d.x,f.maxX)&&(d.x=
27f.maxX+(d.x-f.maxX)/6)):d.x=this.left;return d};h.prototype.isBeyondPossibleLeft=function(a,b){return a>=b};h.prototype.isBeyondPossibleRight=function(a,b){return a<=b};h.prototype.isBeyondPossibleTop=function(a,b){return a>=b};h.prototype.isBeyondPossibleBottom=function(a,b){return a<=b};h.prototype.isImageSlide=function(a){return"image"===this.core.getSlideType(this.core.galleryItems[a])};h.prototype.getPossibleSwipeDragCords=function(a){var b=this.core.getSlideItem(this.core.index).find(".lpc-lg-image").first(),
28c=this.core.mediaContainerPosition.bottom,e=b.get().getBoundingClientRect();b=e.height;e=e.width;a&&(b+=a*b,e+=a*e);return{minY:(b-this.containerRect.height)/2,maxY:(this.containerRect.height-b)/2+c,minX:(e-this.containerRect.width)/2,maxX:(this.containerRect.width-e)/2}};
28h.prototype.setZoomSwipeStyles=function(a,b){a.css("transform","translate3d("+b.x+"px, "+b.y+"px, 0)")};h.prototype.zoomSwipe=function(){var a=this,b={},c={},e=!1,f=!1,d=!1,g=new Date,n=new Date,l,m,p=this.core.getSlideItem(this.core.index);
29this.core.$inner.on("touchstart.lg",function(k){if(a.isImageSlide(a.core.index)&&(p=a.core.getSlideItem(a.core.index),(a.$LG(k.target).hasClass("lpc-lg-item")||p.get().contains(k.target))&&1===k.touches.length&&a.core.outer.hasClass("lpc-lg-zoomed"))){k.preventDefault();g=new Date;a.core.touchAction="zoomSwipe";m=a.core.getSlideItem(a.core.index).find(".lpc-lg-img-wrap").first();var q=a.getDragAllowedAxises(0);d=q.allowY;if((f=q.allowX)||d)b=a.getSwipeCords(k);l=a.getPossibleSwipeDragCords();a.core.outer.addClass("lpc-lg-zoom-dragging lpc-lg-zoom-drag-transition")}});
30this.core.$inner.on("touchmove.lg",function(k){1===k.touches.length&&"zoomSwipe"===a.core.touchAction&&(a.$LG(k.target).hasClass("lpc-lg-item")||p.get().contains(k.target))&&(k.preventDefault(),a.core.touchAction="zoomSwipe",c=a.getSwipeCords(k),k=a.getZoomSwipeCords(b,c,f,d,l),15<Math.abs(c.x-b.x)||15<Math.abs(c.y-b.y))&&(e=!0,a.setZoomSwipeStyles(m,k))});this.core.$inner.on("touchend.lg",function(k){"zoomSwipe"===a.core.touchAction&&(a.$LG(k.target).hasClass("lpc-lg-item")||p.get().contains(k.target))&&
31(k.preventDefault(),a.core.touchAction=void 0,a.core.outer.removeClass("lpc-lg-zoom-dragging"),e&&(e=!1,n=new Date,a.touchendZoom(b,c,f,d,n.valueOf()-g.valueOf())))})};h.prototype.zoomDrag=function(){var a=this,b={},c={},e=!1,f=!1,d=!1,g=!1,n,l,m,p;this.core.outer.on("mousedown.lg.zoom",function(k){if(a.isImageSlide(a.core.index)){var q=a.core.getSlideItem(a.core.index);if(a.$LG(k.target).hasClass("lpc-lg-item")||q.get().contains(k.target))n=new Date,p=a.core.getSlideItem(a.core.index).find(".lpc-lg-img-wrap").first(),
32q=a.getDragAllowedAxises(0),g=q.allowY,d=q.allowX,a.core.outer.hasClass("lpc-lg-zoomed")&&a.$LG(k.target).hasClass("lpc-lg-object")&&(d||g)&&(k.preventDefault(),b=a.getDragCords(k),m=a.getPossibleSwipeDragCords(),e=!0,a.core.outer.removeClass("lpc-lg-grab").addClass("lpc-lg-grabbing lpc-lg-zoom-drag-transition lpc-lg-zoom-dragging"))}});this.$LG(window).on("mousemove.lg.zoom.global"+this.core.lgId,function(k){e&&(f=!0,c=a.getDragCords(k),k=a.getZoomSwipeCords(b,c,d,g,m),a.setZoomSwipeStyles(p,k))});
33this.$LG(window).on("mouseup.lg.zoom.global"+this.core.lgId,function(k){e&&(l=new Date,e=!1,a.core.outer.removeClass("lpc-lg-zoom-dragging"),!f||b.x===c.x&&b.y===c.y||(c=a.getDragCords(k),a.touchendZoom(b,c,d,g,l.valueOf()-n.valueOf())),f=!1);a.core.outer.removeClass("lpc-lg-grabbing").addClass("lpc-lg-grab")})};h.prototype.closeGallery=function(){this.resetZoom();this.zoomInProgress=!1};h.prototype.destroy=function(){this.$LG(window).off(".lg.zoom.global"+this.core.lgId);this.core.LGel.off(".lg.zoom");
34this.core.LGel.off(".zoom");clearTimeout(this.zoomableTimeout);this.zoomableTimeout=!1};return h}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.