lg-7.js 4.8 KB

12
  1. (globalThis.webpackChunksakurairo_scripts=globalThis.webpackChunksakurairo_scripts||[]).push([[868],{3515:function(t){var i,e,r,o,s,a,l,n;t.exports=(i=function(){return(i=Object.assign||function(t){for(var i,e=1,r=arguments.length;e<r;e++)for(var o in i=arguments[e])Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o]);return t}).apply(this,arguments)},e="lgSlideItemLoad",r="lgBeforeSlide",o="lgRotateLeft",s="lgRotateRight",a="lgFlipHorizontal",l="lgFlipVertical",n={rotate:!0,rotateSpeed:400,rotateLeft:!0,rotateRight:!0,flipHorizontal:!0,flipVertical:!0,rotatePluginStrings:{flipVertical:"Flip vertical",flipHorizontal:"Flip horizontal",rotateLeft:"Rotate left",rotateRight:"Rotate right"}},function(){function t(t,e){return this.core=t,this.$LG=e,this.settings=i(i({},n),this.core.settings),this}return t.prototype.buildTemplates=function(){var t="";this.settings.flipVertical&&(t+='<button type="button" id="lg-flip-ver" aria-label="'+this.settings.rotatePluginStrings.flipVertical+'" class="lg-flip-ver lg-icon"></button>'),this.settings.flipHorizontal&&(t+='<button type="button" id="lg-flip-hor" aria-label="'+this.settings.rotatePluginStrings.flipHorizontal+'" class="lg-flip-hor lg-icon"></button>'),this.settings.rotateLeft&&(t+='<button type="button" id="lg-rotate-left" aria-label="'+this.settings.rotatePluginStrings.rotateLeft+'" class="lg-rotate-left lg-icon"></button>'),this.settings.rotateRight&&(t+='<button type="button" id="lg-rotate-right" aria-label="'+this.settings.rotatePluginStrings.rotateRight+'" class="lg-rotate-right lg-icon"></button>'),this.core.$toolbar.append(t)},t.prototype.init=function(){var t=this;this.settings.rotate&&(this.buildTemplates(),this.rotateValuesList={},this.core.LGel.on(e+".rotate",(function(i){var e=i.detail.index;t.core.getSlideItem(e).find(".lg-img-rotate").get()||(t.core.getSlideItem(e).find(".lg-object").first().wrap("lg-img-rotate"),t.core.getSlideItem(t.core.index).find(".lg-img-rotate").css("transition-duration",t.settings.rotateSpeed+"ms"))})),this.core.outer.find("#lg-rotate-left").first().on("click.lg",this.rotateLeft.bind(this)),this.core.outer.find("#lg-rotate-right").first().on("click.lg",this.rotateRight.bind(this)),this.core.outer.find("#lg-flip-hor").first().on("click.lg",this.flipHorizontal.bind(this)),this.core.outer.find("#lg-flip-ver").first().on("click.lg",this.flipVertical.bind(this)),this.core.LGel.on(r+".rotate",(function(i){t.rotateValuesList[i.detail.index]||(t.rotateValuesList[i.detail.index]={rotate:0,flipHorizontal:1,flipVertical:1})})))},t.prototype.applyStyles=function(){this.core.getSlideItem(this.core.index).find(".lg-img-rotate").first().css("transform","rotate("+this.rotateValuesList[this.core.index].rotate+"deg) scale3d("+this.rotateValuesList[this.core.index].flipHorizontal+", "+this.rotateValuesList[this.core.index].flipVertical+", 1)")},t.prototype.rotateLeft=function(){this.rotateValuesList[this.core.index].rotate-=90,this.applyStyles(),this.triggerEvents(o,{rotate:this.rotateValuesList[this.core.index].rotate})},t.prototype.rotateRight=function(){this.rotateValuesList[this.core.index].rotate+=90,this.applyStyles(),this.triggerEvents(s,{rotate:this.rotateValuesList[this.core.index].rotate})},t.prototype.getCurrentRotation=function(t){if(!t)return 0;var i=this.$LG(t).style(),e=i.getPropertyValue("-webkit-transform")||i.getPropertyValue("-moz-transform")||i.getPropertyValue("-ms-transform")||i.getPropertyValue("-o-transform")||i.getPropertyValue("transform")||"none";if("none"!==e){var r=e.split("(")[1].split(")")[0].split(",");if(r){var o=Math.round(Math.atan2(r[1],r[0])*(180/Math.PI));return o<0?o+360:o}}return 0},t.prototype.flipHorizontal=function(){var t=this.core.getSlideItem(this.core.index).find(".lg-img-rotate").first().get(),i=this.getCurrentRotation(t),e="flipHorizontal";90!==i&&270!==i||(e="flipVertical"),this.rotateValuesList[this.core.index][e]*=-1,this.applyStyles(),this.triggerEvents(a,{flipHorizontal:this.rotateValuesList[this.core.index][e]})},t.prototype.flipVertical=function(){var t=this.core.getSlideItem(this.core.index).find(".lg-img-rotate").first().get(),i=this.getCurrentRotation(t),e="flipVertical";90!==i&&270!==i||(e="flipHorizontal"),this.rotateValuesList[this.core.index][e]*=-1,this.applyStyles(),this.triggerEvents(l,{flipVertical:this.rotateValuesList[this.core.index][e]})},t.prototype.triggerEvents=function(t,i){var e=this;setTimeout((function(){e.core.LGel.trigger(t,i)}),this.settings.rotateSpeed+10)},t.prototype.isImageOrientationChanged=function(){var t=this.rotateValuesList[this.core.index],i=Math.abs(t.rotate)%360!=0,e=t.flipHorizontal<0,r=t.flipVertical<0;return i||e||r},t.prototype.closeGallery=function(){this.isImageOrientationChanged()&&this.core.getSlideItem(this.core.index).css("opacity",0),this.rotateValuesList={}},t.prototype.destroy=function(){this.core.LGel.off(".lg.rotate"),this.core.LGel.off(".rotate")},t}())}}]);
  2. //# sourceMappingURL=lg-7.js.map