ngx-pinch-zoom
Version:
Pinch zoom component for Angular.
2 lines • 29.9 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-pinch-zoom",["exports","@angular/core","@angular/common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-pinch-zoom"]={},e.ng.core,e.ng.common)}(this,(function(e,t,i){"use strict";var o={transitionDuration:200,doubleTap:!0,doubleTapScale:2,limitZoom:"original image size",autoZoomOut:!1,zoomControlScale:1,minPanScale:1.0001,minScale:0,listeners:"mouse and touch",wheel:!0,wheelZoomFactor:.2,draggableImage:!1},n={"transition-duration":"transitionDuration",transitionDurationBackwardCompatibility:"transitionDuration","double-tap":"doubleTap",doubleTapBackwardCompatibility:"doubleTap","double-tap-scale":"doubleTapScale",doubleTapScaleBackwardCompatibility:"doubleTapScale","auto-zoom-out":"autoZoomOut",autoZoomOutBackwardCompatibility:"autoZoomOut","limit-zoom":"limitZoom",limitZoomBackwardCompatibility:"limitZoom"},s=function(){function e(e){var t=this;this.eventType=void 0,this.handlers={},this.startX=0,this.startY=0,this.lastTap=0,this.doubleTapMinTimeout=300,this.tapMinTimeout=200,this.touchstartTime=0,this.i=0,this.isMousedown=!1,this._touchListeners={touchstart:"handleTouchstart",touchmove:"handleTouchmove",touchend:"handleTouchend"},this._mouseListeners={mousedown:"handleMousedown",mousemove:"handleMousemove",mouseup:"handleMouseup",wheel:"handleWheel"},this._otherListeners={resize:"handleResize"},this.handleTouchstart=function(e){t.elementPosition=t.getElementPosition(),t.touchstartTime=(new Date).getTime(),void 0===t.eventType&&t.getTouchstartPosition(e),t.runHandler("touchstart",e)},this.handleTouchmove=function(e){var i=e.touches;t.detectPan(i)&&t.runHandler("pan",e),t.detectPinch(e)&&t.runHandler("pinch",e)},this.handleTouchend=function(e){var i=e.touches;t.detectDoubleTap()&&t.runHandler("double-tap",e),t.detectTap(),t.runHandler("touchend",e),t.eventType="touchend",i&&0===i.length&&(t.eventType=void 0,t.i=0)},this.handleMousedown=function(e){t.isMousedown=!0,t.elementPosition=t.getElementPosition(),t.touchstartTime=(new Date).getTime(),void 0===t.eventType&&t.getMousedownPosition(e),t.runHandler("mousedown",e)},this.handleMousemove=function(e){if(t.isMousedown){switch(t.runHandler("pan",e),t.detectLinearSwipe(e)){case"horizontal-swipe":e.swipeType="horizontal-swipe",t.runHandler("horizontal-swipe",e);break;case"vertical-swipe":e.swipeType="vertical-swipe",t.runHandler("vertical-swipe",e)}(t.detectLinearSwipe(e)||"horizontal-swipe"===t.eventType||"vertical-swipe"===t.eventType)&&t.handleLinearSwipe(e)}},this.handleMouseup=function(e){t.detectTap(),t.isMousedown=!1,t.runHandler("mouseup",e),t.eventType=void 0,t.i=0},this.handleWheel=function(e){t.runHandler("wheel",e)},this.handleResize=function(e){t.runHandler("resize",e)},this.properties=e,this.element=this.properties.element,this.elementPosition=this.getElementPosition(),this.toggleEventListeners("addEventListener")}return Object.defineProperty(e.prototype,"touchListeners",{get:function(){return this.properties.touchListeners?this.properties.touchListeners:this._touchListeners},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mouseListeners",{get:function(){return this.properties.mouseListeners?this.properties.mouseListeners:this._mouseListeners},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"otherListeners",{get:function(){return this.properties.otherListeners?this.properties.otherListeners:this._otherListeners},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){this.toggleEventListeners("removeEventListener")},e.prototype.toggleEventListeners=function(e){var t;for(var i in t="mouse and touch"===this.properties.listeners?Object.assign(this.touchListeners,this.mouseListeners):this.detectTouchScreen()?this.touchListeners:this.mouseListeners,this.properties.resize&&(t=Object.assign(t,this.otherListeners)),t){var o=t[i];"resize"===i?("addEventListener"===e&&window.addEventListener(i,this[o],!1),"removeEventListener"===e&&window.removeEventListener(i,this[o],!1)):"mouseup"===i||"mousemove"===i?("addEventListener"===e&&document.addEventListener(i,this[o],!1),"removeEventListener"===e&&document.removeEventListener(i,this[o],!1)):("addEventListener"===e&&this.element.addEventListener(i,this[o],!1),"removeEventListener"===e&&this.element.removeEventListener(i,this[o],!1))}},e.prototype.addEventListeners=function(e){var t=this._mouseListeners[e];window.addEventListener(e,this[t],!1)},e.prototype.removeEventListeners=function(e){var t=this._mouseListeners[e];window.removeEventListener(e,this[t],!1)},e.prototype.handleLinearSwipe=function(e){this.i++,this.i>3&&(this.eventType=this.getLinearSwipeType(e)),"horizontal-swipe"===this.eventType&&this.runHandler("horizontal-swipe",e),"vertical-swipe"===this.eventType&&this.runHandler("vertical-swipe",e)},e.prototype.runHandler=function(e,t){this.handlers[e]&&this.handlers[e](t)},e.prototype.detectPan=function(e){return 1===e.length&&!this.eventType||"pan"===this.eventType},e.prototype.detectDoubleTap=function(){var e=this;if(null==this.eventType){var t=(new Date).getTime(),i=t-this.lastTap;if(clearTimeout(this.doubleTapTimeout),i<this.doubleTapMinTimeout&&i>0)return!0;this.doubleTapTimeout=setTimeout((function(){clearTimeout(e.doubleTapTimeout)}),this.doubleTapMinTimeout),this.lastTap=t}},e.prototype.detectTap=function(){if(null==this.eventType){var e=(new Date).getTime()-this.touchstartTime;e>0&&(e<this.tapMinTimeout?this.runHandler("tap",{}):this.runHandler("longtap",{}))}},e.prototype.detectPinch=function(e){return 2===e.touches.length&&void 0===this.eventType||"pinch"===this.eventType},e.prototype.detectLinearSwipe=function(e){var t=e.touches;if(t){if(1===t.length&&!this.eventType||"horizontal-swipe"===this.eventType||"vertical-swipe"===this.eventType)return this.getLinearSwipeType(e)}else if(!this.eventType||"horizontal-swipe"===this.eventType||"vertical-swipe"===this.eventType)return this.getLinearSwipeType(e)},e.prototype.getLinearSwipeType=function(e){if("horizontal-swipe"!==this.eventType&&"vertical-swipe"!==this.eventType){var t=Math.abs(this.moveLeft(0,e)-this.startX);return 3*Math.abs(this.moveTop(0,e)-this.startY)>t?"vertical-swipe":"horizontal-swipe"}return this.eventType},e.prototype.getElementPosition=function(){return this.element.getBoundingClientRect()},e.prototype.getTouchstartPosition=function(e){this.startX=e.touches[0].clientX-this.elementPosition.left,this.startY=e.touches[0].clientY-this.elementPosition.top},e.prototype.getMousedownPosition=function(e){this.startX=e.clientX-this.elementPosition.left,this.startY=e.clientY-this.elementPosition.top},e.prototype.moveLeft=function(e,t){var i=t.touches;return i?i[e].clientX-this.elementPosition.left:t.clientX-this.elementPosition.left},e.prototype.moveTop=function(e,t){var i=t.touches;return i?i[e].clientY-this.elementPosition.top:t.clientY-this.elementPosition.top},e.prototype.detectTouchScreen=function(){var e=" -webkit- -moz- -o- -ms- ".split(" ");return"ontouchstart"in window||function(e){return window.matchMedia(e).matches}(["(",e.join("touch-enabled),("),"heartz",")"].join(""))},e.prototype.on=function(e,t){e&&(this.handlers[e]=t)},e}(),r=function(){function e(e){var t=this;this.properties=o,this.i=0,this.scale=1,this.initialScale=1,this.startX=0,this.startY=0,this.moveX=0,this.moveY=0,this.initialMoveX=0,this.initialMoveY=0,this.moveXC=0,this.moveYC=0,this.lastTap=0,this.draggingMode=!1,this.distance=0,this.doubleTapTimeout=0,this.initialDistance=0,this.events={},this.defaultMaxScale=3,this.handleTouchstart=function(e){t.touches.addEventListeners("mousemove","handleMousemove"),t.getElementPosition(),void 0===t.eventType&&t.getTouchstartPosition(e)},this.handleTouchend=function(e){if("touchend"===e.type){t.i=0,t.draggingMode=!1;var i=e.touches;t.scale<1&&(t.scale=1),t.properties.autoZoomOut&&"pinch"===t.eventType&&(t.scale=1),("pinch"===t.eventType||"pan"===t.eventType&&t.scale>t.minPanScale)&&t.alignImage(),"pinch"!==t.eventType&&"pan"!==t.eventType&&"horizontal-swipe"!==t.eventType&&"vertical-swipe"!==t.eventType||t.updateInitialValues(),t.eventType="touchend",i&&0===i.length&&(t.eventType=void 0)}"mouseup"===e.type&&(t.draggingMode=!1,t.updateInitialValues(),t.eventType=void 0),t.touches.removeEventListeners("mousemove","handleMousemove")},this.handlePan=function(e){if(!(t.scale<t.minPanScale||t.properties.disablePan)){e.preventDefault();var i=t.getClientPosition(e),o=i.clientX,n=i.clientY;t.eventType||(t.startX=o-t.elementPosition.left,t.startY=n-t.elementPosition.top),t.eventType="pan",t.moveX=t.initialMoveX+(t.moveLeft(e,0)-t.startX),t.moveY=t.initialMoveY+(t.moveTop(e,0)-t.startY),t.properties.limitPan&&(t.limitPanY(),t.limitPanX()),"mousemove"===e.type&&t.scale>t.minPanScale&&t.centeringImage(),t.transformElement(0)}},this.handleDoubleTap=function(e){t.toggleZoom(e)},this.handlePinch=function(e){if(e.preventDefault(),void 0===t.eventType||"pinch"===t.eventType){var i=e.touches;if(!t.eventType){t.initialDistance=t.getDistance(i);var o=t.moveLeft(e,0),n=t.moveLeft(e,1),s=t.moveTop(e,0),r=t.moveTop(e,1);t.moveXC=(o+n)/2-t.initialMoveX,t.moveYC=(s+r)/2-t.initialMoveY}t.eventType="pinch",t.distance=t.getDistance(i),t.scale=t.initialScale*(t.distance/t.initialDistance),t.moveX=t.initialMoveX-(t.distance/t.initialDistance*t.moveXC-t.moveXC),t.moveY=t.initialMoveY-(t.distance/t.initialDistance*t.moveYC-t.moveYC),t.handleLimitZoom(),t.properties.limitPan&&(t.limitPanY(),t.limitPanX()),t.transformElement(0)}},this.handleWheel=function(e){e.preventDefault();var i=t.properties.wheelZoomFactor||0,o=e.deltaY<0?i:-i,n=t.initialScale+o;if(n<1+i?n=1:n<t.maxScale&&n>t.maxScale-i&&(n=t.maxScale),!(n<1||n>t.maxScale)&&n!==t.scale){t.getElementPosition(),t.scale=n;var s=e.clientX-t.elementPosition.left-t.initialMoveX,r=e.clientY-t.elementPosition.top-t.initialMoveY;t.setZoom({scale:n,center:[s,r]})}},this.handleResize=function(e){t.setAutoHeight()},this.element=e.element,this.element&&(this.elementTarget=this.element.querySelector("*").tagName,this.parentElement=this.element.parentElement,this.properties=Object.assign({},o,e),this.detectLimitZoom(),this.touches=new s({element:e.element,listeners:e.listeners,resize:e.autoHeight,mouseListeners:{mousedown:"handleMousedown",mouseup:"handleMouseup",wheel:"handleWheel"}}),this.setBasicStyles(),this.touches.on("touchstart",this.handleTouchstart),this.touches.on("touchend",this.handleTouchend),this.touches.on("mousedown",this.handleTouchstart),this.touches.on("mouseup",this.handleTouchend),this.touches.on("pan",this.handlePan),this.touches.on("mousemove",this.handlePan),this.touches.on("pinch",this.handlePinch),this.properties.wheel&&this.touches.on("wheel",this.handleWheel),this.properties.doubleTap&&this.touches.on("double-tap",this.handleDoubleTap),this.properties.autoHeight&&this.touches.on("resize",this.handleResize))}return Object.defineProperty(e.prototype,"minPanScale",{get:function(){return this.getPropertiesValue("minPanScale")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fullImage",{get:function(){return this.properties.fullImage},enumerable:!1,configurable:!0}),e.prototype.handleLimitZoom=function(){var e=this.maxScale,t=this.properties.minScale||0;if(this.scale>e||this.scale<=t){var i=this.getImageWidth(),o=this.getImageHeight(),n=i*this.scale,s=o*this.scale,r=this.moveX/(n-i),a=this.moveY/(s-o);this.scale>e&&(this.scale=e),this.scale<=t&&(this.scale=t);var l=i*this.scale,p=o*this.scale;this.moveX=-Math.abs(r*(l-i)),this.moveY=-Math.abs(-a*(p-o))}},e.prototype.moveLeft=function(e,t){return void 0===t&&(t=0),this.getClientPosition(e,t).clientX-this.elementPosition.left},e.prototype.moveTop=function(e,t){return void 0===t&&(t=0),this.getClientPosition(e,t).clientY-this.elementPosition.top},e.prototype.centeringImage=function(){var e=this.element.getElementsByTagName(this.elementTarget)[0],t=this.moveX,i=this.moveY;return this.moveY>0&&(this.moveY=0),this.moveX>0&&(this.moveX=0),e&&(this.limitPanY(),this.limitPanX()),e&&this.scale<1&&this.moveX<this.element.offsetWidth*(1-this.scale)&&(this.moveX=this.element.offsetWidth*(1-this.scale)),t!==this.moveX||i!==this.moveY},e.prototype.limitPanY=function(){var e=this.getImageHeight(),t=e*this.scale,i=this.parentElement.offsetHeight,o=this.element.offsetHeight;if(t<i)this.moveY=(i-o*this.scale)/2;else{var n=(e-o)*this.scale/2;this.moveY>n?this.moveY=n:t+Math.abs(n)-i+this.moveY<0&&(this.moveY=-(t+Math.abs(n)-i))}},e.prototype.limitPanX=function(){var e=this.getImageWidth(),t=e*this.scale,i=this.parentElement.offsetWidth,o=this.element.offsetWidth;if(t<i)this.moveX=(i-o*this.scale)/2;else{var n=(e-o)*this.scale/2;this.moveX>n?this.moveX=n:t+Math.abs(n)-i+this.moveX<0&&(this.moveX=-(e*this.scale+Math.abs(n)-i))}},e.prototype.setBasicStyles=function(){this.element.style.display="flex",this.element.style.alignItems="center",this.element.style.justifyContent="center",this.element.style.transformOrigin="0 0",this.setImageSize(),this.setDraggableImage()},e.prototype.removeBasicStyles=function(){this.element.style.display="",this.element.style.alignItems="",this.element.style.justifyContent="",this.element.style.transformOrigin="",this.removeImageSize(),this.removeDraggableImage()},e.prototype.setDraggableImage=function(){var e=this.getImageElement();e&&(e.draggable=this.properties.draggableImage)},e.prototype.removeDraggableImage=function(){var e=this.getImageElement();e&&(e.draggable=!0)},e.prototype.setImageSize=function(){var e=this.element.getElementsByTagName(this.elementTarget);e.length&&(e[0].style.maxWidth="100%",e[0].style.maxHeight="100%",this.setAutoHeight())},e.prototype.setAutoHeight=function(){var e=this.element.getElementsByTagName(this.elementTarget);if(this.properties.autoHeight&&e.length){var t=e[0].getAttribute("width")/e[0].getAttribute("height"),i=this.parentElement.offsetWidth;e[0].style.maxHeight=i/t+"px"}},e.prototype.removeImageSize=function(){var e=this.element.getElementsByTagName(this.elementTarget);e.length&&(e[0].style.maxWidth="",e[0].style.maxHeight="")},e.prototype.getElementPosition=function(){this.elementPosition=this.element.parentElement.getBoundingClientRect()},e.prototype.getTouchstartPosition=function(e){var t=this.getClientPosition(e),i=t.clientX,o=t.clientY;this.startX=i-this.elementPosition.left,this.startY=o-this.elementPosition.top},e.prototype.getClientPosition=function(e,t){var i,o;return void 0===t&&(t=0),"touchstart"!==e.type&&"touchmove"!==e.type||(i=e.touches[t].clientX,o=e.touches[t].clientY),"mousedown"!==e.type&&"mousemove"!==e.type||(i=e.clientX,o=e.clientY),{clientX:i,clientY:o}},e.prototype.resetScale=function(){this.scale=1,this.moveX=0,this.moveY=0,this.updateInitialValues(),this.transformElement(this.properties.transitionDuration)},e.prototype.updateInitialValues=function(){this.initialScale=this.scale,this.initialMoveX=this.moveX,this.initialMoveY=this.moveY},e.prototype.getDistance=function(e){return Math.sqrt(Math.pow(e[0].pageX-e[1].pageX,2)+Math.pow(e[0].pageY-e[1].pageY,2))},e.prototype.getImageHeight=function(){return this.element.getElementsByTagName(this.elementTarget)[0].offsetHeight},e.prototype.getImageWidth=function(){return this.element.getElementsByTagName(this.elementTarget)[0].offsetWidth},e.prototype.transformElement=function(e){this.element.style.transition="all "+e+"ms",this.element.style.transform="matrix("+Number(this.scale)+", 0, 0, "+Number(this.scale)+", "+Number(this.moveX)+", "+Number(this.moveY)+")"},e.prototype.isTouchScreen=function(){var e=" -webkit- -moz- -o- -ms- ".split(" ");if("ontouchstart"in window)return!0;var t=["(",e.join("touch-enabled),("),"heartz",")"].join("");return this.getMatchMedia(t)},e.prototype.getMatchMedia=function(e){return window.matchMedia(e).matches},e.prototype.isDragging=function(){if(this.properties.disablePan)return!1;var e=this.getImageHeight(),t=this.getImageWidth();return this.scale>1?e*this.scale>this.parentElement.offsetHeight||t*this.scale>this.parentElement.offsetWidth:1===this.scale?e>this.parentElement.offsetHeight||t>this.parentElement.offsetWidth:void 0},e.prototype.detectLimitZoom=function(){this.maxScale=this.defaultMaxScale,"original image size"===this.properties.limitZoom&&"IMG"===this.elementTarget&&this.pollLimitZoomForOriginalImage()},e.prototype.pollLimitZoomForOriginalImage=function(){var e=this,t=setInterval((function(){var i=e.getMaxScaleForOriginalImage();"number"==typeof i&&(e.maxScale=i,clearInterval(t))}),10)},e.prototype.getMaxScaleForOriginalImage=function(){var e,t=this.element.getElementsByTagName("img")[0];return t.naturalWidth&&t.offsetWidth&&(e=t.naturalWidth/t.offsetWidth),e},e.prototype.getImageElement=function(){var e=this.element.getElementsByTagName(this.elementTarget);if(e.length)return e[0]},e.prototype.toggleZoom=function(e){if(void 0===e&&(e=!1),1===this.initialScale){if(e&&e.changedTouches){if(void 0===this.properties.doubleTapScale)return;var t=e.changedTouches;this.scale=this.initialScale*this.properties.doubleTapScale,this.moveX=this.initialMoveX-(t[0].clientX-this.elementPosition.left)*(this.properties.doubleTapScale-1),this.moveY=this.initialMoveY-(t[0].clientY-this.elementPosition.top)*(this.properties.doubleTapScale-1)}else{var i=this.properties.zoomControlScale||0;this.scale=this.initialScale*(i+1),this.moveX=this.initialMoveX-this.element.offsetWidth*(this.scale-1)/2,this.moveY=this.initialMoveY-this.element.offsetHeight*(this.scale-1)/2}this.centeringImage(),this.updateInitialValues(),this.transformElement(this.properties.transitionDuration)}else this.resetScale()},e.prototype.setZoom=function(e){var t,i;this.scale=e.scale;var o=this.element.offsetWidth,n=this.element.offsetHeight,s=o*this.scale/(o*this.initialScale);e.center?(t=e.center[0],i=e.center[1]):(t=o/2-this.initialMoveX,i=n/2-this.initialMoveY),this.moveX=this.initialMoveX-(s*t-t),this.moveY=this.initialMoveY-(s*i-i),this.centeringImage(),this.updateInitialValues(),this.transformElement(this.properties.transitionDuration)},e.prototype.alignImage=function(){this.centeringImage()&&(this.updateInitialValues(),this.transformElement(this.properties.transitionDuration))},e.prototype.destroy=function(){this.removeBasicStyles(),this.touches.destroy()},e.prototype.getPropertiesValue=function(e){return this.properties&&this.properties[e]?this.properties[e]:o[e]},e}(),a={overflow:"hidden",disableZoomControl:"auto",backgroundColor:"rgba(0,0,0,0.85)"},l=function(){function e(e){this.elementRef=e,this.defaultComponentProperties=this.getDefaultComponentProperties(),this.applyPropertiesDefault(this.defaultComponentProperties,{})}return Object.defineProperty(e.prototype,"properties",{get:function(){return this._properties},set:function(e){e&&(this._properties=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transitionDurationBackwardCompatibility",{set:function(e){e&&(this._transitionDuration=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transitionDuration",{get:function(){return this._transitionDuration},set:function(e){e&&(this._transitionDuration=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleTapBackwardCompatibility",{set:function(e){e&&(this._doubleTap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleTap",{get:function(){return this._doubleTap},set:function(e){e&&(this._doubleTap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleTapScaleBackwardCompatibility",{set:function(e){e&&(this._doubleTapScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleTapScale",{get:function(){return this._doubleTapScale},set:function(e){e&&(this._doubleTapScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoZoomOutBackwardCompatibility",{set:function(e){e&&(this._autoZoomOut=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoZoomOut",{get:function(){return this._autoZoomOut},set:function(e){e&&(this._autoZoomOut=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"limitZoomBackwardCompatibility",{set:function(e){e&&(this._limitZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"limitZoom",{get:function(){return this._limitZoom},set:function(e){e&&(this._limitZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostOverflow",{get:function(){return this.properties.overflow},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hostBackgroundColor",{get:function(){return this.properties.backgroundColor},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTouchScreen",{get:function(){var e=" -webkit- -moz- -o- -ms- ".split(" ");return"ontouchstart"in window||function(e){return window.matchMedia(e).matches}(["(",e.join("touch-enabled),("),"heartz",")"].join(""))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDragging",{get:function(){return this.pinchZoom?this.pinchZoom.isDragging():void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this.properties.disabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.pinchZoom.scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isZoomedIn",{get:function(){return this.scale>1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleLevel",{get:function(){return Math.round(this.scale/this._zoomControlScale)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScale",{get:function(){return this.pinchZoom.maxScale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isZoomLimitReached",{get:function(){return this.scale>=this.maxScale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_zoomControlScale",{get:function(){return this.getPropertiesValue("zoomControlScale")},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){this.initPinchZoom(),this.detectLimitZoom()},e.prototype.ngOnChanges=function(e){var t=this.getProperties(e);t=this.renameProperties(t),this.applyPropertiesDefault(this.defaultComponentProperties,t)},e.prototype.ngOnDestroy=function(){this.destroy()},e.prototype.initPinchZoom=function(){this.properties.disabled||(this.properties.element=this.elementRef.nativeElement.querySelector(".pinch-zoom-content"),this.pinchZoom=new r(this.properties))},e.prototype.getProperties=function(e){var t={};for(var i in e)"properties"!==i&&(t[i]=e[i].currentValue),"properties"===i&&(t=e[i].currentValue);return t},e.prototype.renameProperties=function(e){for(var t in e)n[t]&&(e[n[t]]=e[t],delete e[t]);return e},e.prototype.applyPropertiesDefault=function(e,t){this.properties=Object.assign({},e,t)},e.prototype.toggleZoom=function(){this.pinchZoom.toggleZoom()},e.prototype.isControl=function(){return!this.isDisabled&&("disable"!==this.properties.disableZoomControl&&(!this.isTouchScreen||"auto"!==this.properties.disableZoomControl))},e.prototype.detectLimitZoom=function(){this.pinchZoom&&this.pinchZoom.detectLimitZoom()},e.prototype.destroy=function(){this.pinchZoom.destroy()},e.prototype.getPropertiesValue=function(e){return this.properties&&this.properties[e]?this.properties[e]:this.defaultComponentProperties[e]},e.prototype.getDefaultComponentProperties=function(){return Object.assign(Object.assign({},o),a)},e}();l.decorators=[{type:t.Component,args:[{selector:"pinch-zoom, [pinch-zoom]",exportAs:"pinchZoom",template:'<div class="pinch-zoom-content" [class.pz-dragging]="isDragging">\n\t<ng-content></ng-content>\n</div>\n\n\x3c!-- Control: one button --\x3e\n<div class="pz-zoom-button pz-zoom-control-position-bottom" \n\t[class.pz-zoom-button-out]="isZoomedIn" \n\t*ngIf="isControl()" \n\t(click)="toggleZoom()"></div>',styles:[":host{display:block;overflow:hidden;position:relative}.pinch-zoom-content{height:inherit}.pz-dragging{cursor:all-scroll}.pz-zoom-button{-webkit-user-select:none;background-color:rgba(0,0,0,.8);background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgc3R5bGU9IiI+PHJlY3QgaWQ9ImJhY2tncm91bmRyZWN0IiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4PSIwIiB5PSIwIiBmaWxsPSJub25lIiBzdHJva2U9Im5vbmUiLz48ZyBjbGFzcz0iY3VycmVudExheWVyIiBzdHlsZT0iIj48dGl0bGU+TGF5ZXIgMTwvdGl0bGU+PHBhdGggZD0iTTE1LjUgMTRoLS43OWwtLjI4LS4yN0MxNS40MSAxMi41OSAxNiAxMS4xMSAxNiA5LjUgMTYgNS45MSAxMy4wOSAzIDkuNSAzUzMgNS45MSAzIDkuNSA1LjkxIDE2IDkuNSAxNmMxLjYxIDAgMy4wOS0uNTkgNC4yMy0xLjU3bC4yNy4yOHYuNzlsNSA0Ljk5TDIwLjQ5IDE5bC00Ljk5LTV6bS02IDBDNy4wMSAxNCA1IDExLjk5IDUgOS41UzcuMDEgNSA5LjUgNSAxNCA3LjAxIDE0IDkuNSAxMS45OSAxNCA5LjUgMTR6IiBpZD0ic3ZnXzEiIGNsYXNzPSIiIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMSIvPjxwYXRoIGQ9Ik0xMiAxMGgtMnYySDl2LTJIN1Y5aDJWN2gxdjJoMnYxeiIgaWQ9InN2Z18zIiBjbGFzcz0iIiBmaWxsPSIjZmZmZmZmIiBmaWxsLW9wYWNpdHk9IjEiLz48L2c+PC9zdmc+),url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCI+PHJlY3QgaWQ9ImJhY2tncm91bmRyZWN0IiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4PSIwIiB5PSIwIiBmaWxsPSJub25lIiBzdHJva2U9Im5vbmUiLz48ZyBjbGFzcz0iY3VycmVudExheWVyIiBzdHlsZT0iIj48dGl0bGU+TGF5ZXIgMTwvdGl0bGU+PHBhdGggZD0iTTE1LjUgMTRoLS43OWwtLjI4LS4yN0MxNS40MSAxMi41OSAxNiAxMS4xMSAxNiA5LjUgMTYgNS45MSAxMy4wOSAzIDkuNSAzUzMgNS45MSAzIDkuNSA1LjkxIDE2IDkuNSAxNmMxLjYxIDAgMy4wOS0uNTkgNC4yMy0xLjU3bC4yNy4yOHYuNzlsNSA0Ljk5TDIwLjQ5IDE5bC00Ljk5LTV6bS02IDBDNy4wMSAxNCA1IDExLjk5IDUgOS41UzcuMDEgNSA5LjUgNSAxNCA3LjAxIDE0IDkuNSAxMS45OSAxNCA5LjUgMTR6TTcgOWg1djFIN3oiIGlkPSJzdmdfMiIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8+PC9nPjwvc3ZnPg==);background-position:50%,-1000px;background-repeat:no-repeat,no-repeat;background-size:40px;border-radius:4px;color:#fff;cursor:pointer;height:56px;opacity:.5;position:absolute;transition:opacity .1s;user-select:none;width:56px;z-index:1000}.pz-zoom-button-out{background-position:-1000px,50%}.pz-zoom-button:hover{opacity:.7}.pz-zoom-button.pz-zoom-control-position-right{margin-top:-28px;right:16px;top:50%}.pz-zoom-button.pz-zoom-control-position-right-bottom{bottom:32px;right:16px}.pz-zoom-button.pz-zoom-control-position-bottom{bottom:16px;left:50%;margin-left:-28px}.pz-zoom-control{background-color:rgba(0,0,0,.8);border-radius:4px;overflow:hidden;position:absolute}.pz-zoom-control.pz-zoom-control-position-right{margin-top:-48px;right:16px;top:50%}.pz-zoom-control.pz-zoom-control-position-right-bottom{bottom:32px;right:16px}.pz-zoom-control.pz-zoom-control-position-bottom{bottom:16px;left:50%;margin-left:-48px}.pz-zoom-in,.pz-zoom-out{background-position:50%;background-repeat:no-repeat;cursor:pointer;height:48px;opacity:1;width:48px}.pz-zoom-in:hover,.pz-zoom-out:hover{background-color:hsla(0,0%,100%,.2)}.pz-zoom-control-position-bottom .pz-zoom-in,.pz-zoom-control-position-bottom .pz-zoom-out{float:right}.pz-disabled{cursor:default;opacity:.5}.pz-disabled:hover{background-color:hsla(0,0%,100%,0)}.pz-zoom-in{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgc3R5bGU9IiI+PHJlY3QgaWQ9ImJhY2tncm91bmRyZWN0IiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4PSIwIiB5PSIwIiBmaWxsPSJub25lIiBzdHJva2U9Im5vbmUiLz48ZyBjbGFzcz0iY3VycmVudExheWVyIiBzdHlsZT0iIj48dGl0bGU+TGF5ZXIgMTwvdGl0bGU+PHBhdGggZD0iTTE5IDEzaC02djZoLTJ2LTZINXYtMmg2VjVoMnY2aDZ2MnoiIGlkPSJzdmdfMSIgY2xhc3M9IiIgc3Ryb2tlPSJub25lIiBmaWxsPSIjZmZmZmZmIiBmaWxsLW9wYWNpdHk9IjEiLz48cGF0aCBkPSJNLTE1LjgzNjczNDQyMDQ2MTY1Myw0NC41MzU0MDkzMDY3MTAxOCBoNTguMjA0MDgwODI3NTkzMDkgdi02LjU3NjIyNjcyMzM2OTIyMTUgSC0xNS44MzY3MzQ0MjA0NjE2NTMgeiIgZmlsbD0ibm9uZSIgaWQ9InN2Z18yIiBjbGFzcz0iIiBzdHJva2U9Im5vbmUiLz48L2c+PC9zdmc+)}.pz-zoom-out{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCI+PHJlY3QgaWQ9ImJhY2tncm91bmRyZWN0IiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4PSIwIiB5PSIwIiBmaWxsPSJub25lIiBzdHJva2U9Im5vbmUiLz48ZyBjbGFzcz0iY3VycmVudExheWVyIiBzdHlsZT0iIj48dGl0bGU+TGF5ZXIgMTwvdGl0bGU+PHBhdGggZD0iTTE5IDEzSDV2LTJoMTR2MnoiIGlkPSJzdmdfMSIgY2xhc3M9IiIgZmlsbD0iI2ZmZmZmZiIgZmlsbC1vcGFjaXR5PSIxIi8+PC9nPjwvc3ZnPg==)}"]}]}],l.ctorParameters=function(){return[{type:t.ElementRef}]},l.propDecorators={properties:[{type:t.Input,args:["properties"]}],transitionDurationBackwardCompatibility:[{type:t.Input,args:["transition-duration"]}],transitionDuration:[{type:t.Input,args:["transitionDuration"]}],doubleTapBackwardCompatibility:[{type:t.Input,args:["double-tap"]}],doubleTap:[{type:t.Input,args:["doubleTap"]}],doubleTapScaleBackwardCompatibility:[{type:t.Input,args:["double-tap-scale"]}],doubleTapScale:[{type:t.Input,args:["doubleTapScale"]}],autoZoomOutBackwardCompatibility:[{type:t.Input,args:["auto-zoom-out"]}],autoZoomOut:[{type:t.Input,args:["autoZoomOut"]}],limitZoomBackwardCompatibility:[{type:t.Input,args:["limit-zoom"]}],limitZoom:[{type:t.Input,args:["limitZoom"]}],disabled:[{type:t.Input}],disablePan:[{type:t.Input}],overflow:[{type:t.Input}],zoomControlScale:[{type:t.Input}],disableZoomControl:[{type:t.Input}],backgroundColor:[{type:t.Input}],limitPan:[{type:t.Input}],minPanScale:[{type:t.Input}],minScale:[{type:t.Input}],listeners:[{type:t.Input}],wheel:[{type:t.Input}],autoHeight:[{type:t.Input}],wheelZoomFactor:[{type:t.Input}],draggableImage:[{type:t.Input}],hostOverflow:[{type:t.HostBinding,args:["style.overflow"]}],hostBackgroundColor:[{type:t.HostBinding,args:["style.background-color"]}]};var p=function(){};p.decorators=[{type:t.NgModule,args:[{declarations:[l],imports:[i.CommonModule],exports:[l],providers:[],bootstrap:[],entryComponents:[l]}]}],e.PinchZoomComponent=l,e.PinchZoomModule=p,e._defaultComponentProperties=a,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-pinch-zoom.umd.min.js.map