Socket
Socket
Sign inDemoInstall

react-viewer

Package Overview
Dependencies
1
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.11.0 to 2.11.1

3

dist/index.js

@@ -857,2 +857,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

e.preventDefault();
e.stopPropagation();
}

@@ -1063,3 +1064,3 @@ };

if (!this.props.disableKeyboardSupport) {
document[funcName]('keydown', this.handleKeydown, false);
document[funcName]('keydown', this.handleKeydown, true);
}

@@ -1066,0 +1067,0 @@ };

@@ -6,2 +6,2 @@ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports["react-viewer"]=t(require("react"),require("react-dom")):e["react-viewer"]=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(5),r=o(i);t.default=r.default,e.exports=t.default},function(t,n){t.exports=e},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):i(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.ActionType=void 0;var l=n(1),c=o(l),p=t.ActionType=void 0;!function(e){e[e.zoomIn=1]="zoomIn",e[e.zoomOut=2]="zoomOut",e[e.prev=3]="prev",e[e.next=4]="next",e[e.rotateLeft=5]="rotateLeft",e[e.rotateRight=6]="rotateRight",e[e.reset=7]="reset",e[e.close=8]="close",e[e.scaleX=9]="scaleX",e[e.scaleY=10]="scaleY",e[e.download=11]="download"}(p||(t.ActionType=p={}));var u=function(e){function t(){return r(this,t),a(this,e.apply(this,arguments))}return s(t,e),t.prototype.render=function(){var e="react-viewer-icon";return c.createElement("i",{className:e+" "+e+"-"+p[this.props.type]})},t}(c.Component);t.default=u},function(e,t,n){var o,i;/*!

*/
!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var a=n.apply(null,o);a&&e.push(a)}else if("object"===i)for(var s in o)r.call(o,s)&&o[s]&&e.push(s)}}return e.join(" ")}var r={}.hasOwnProperty;"undefined"!=typeof e&&e.exports?(n.default=n,e.exports=n):(o=[],i=function(){return n}.apply(t,o),!(void 0!==i&&(e.exports=i)))}()},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):i(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=n(1),c=o(l),p=function(e){function t(){return r(this,t),a(this,e.call(this))}return s(t,e),t.prototype.render=function(){var e="circle-loading";return c.createElement("div",{className:"loading-wrap",style:this.props.style},c.createElement("div",{className:e}))},t}(c.Component);t.default=p,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var c=n(1),p=i(c),u=n(12),h=i(u),f=n(7),d=o(f),v=function(e){function t(){a(this,t);var n=s(this,e.call(this));return n.container=null,n.defaultContainer=null,"undefined"!=typeof document&&n.setDefaultContainer(),n.component=null,n}return l(t,e),t.prototype.setDefaultContainer=function(){this.defaultContainer=document.createElement("div")},t.prototype.renderViewer=function(){if(this.props.visible||this.component){this.container||(this.props.container?this.container=this.props.container:(this.defaultContainer||this.setDefaultContainer(),this.container=this.defaultContainer,document.body.appendChild(this.container)));var e=this;h.unstable_renderSubtreeIntoContainer(this,p.createElement(d.default,this.props),this.container,function(){e.component=this})}},t.prototype.removeViewer=function(){if(this.container){var e=this.container;h.unmountComponentAtNode(e),e.parentNode.removeChild(e),this.container=null,this.component=null}},t.prototype.componentWillUnmount=function(){this.props.visible&&this.props.onClose&&this.props.onClose(),this.removeViewer()},t.prototype.componentDidMount=function(){this.renderViewer()},t.prototype.componentDidUpdate=function(e){this.props.container!==e.container&&(this.component=null,this.props.container?(this.container&&!e.container&&document.body.removeChild(this.container),this.container=this.props.container):(this.container=this.defaultContainer,document.body.appendChild(this.container))),this.renderViewer()},t.prototype.render=function(){return null},t}(p.Component);t.default=v,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var p=n(1),u=i(p),h=n(4),f=o(h),d=n(3),v=o(d),y=function(e){function t(){s(this,t);var n=l(this,e.call(this));return n.handleResize=function(e){n.props.onResize()},n.handleCanvasMouseDown=function(e){n.props.onCanvasMouseDown(e),n.handleMouseDown(e)},n.handleMouseDown=function(e){0===e.button&&n.props.visible&&n.props.drag&&(e.preventDefault(),e.stopPropagation(),n.setState({isMouseDown:!0,mouseX:e.nativeEvent.clientX,mouseY:e.nativeEvent.clientY}))},n.handleMouseMove=function(e){if(n.state.isMouseDown){var t=e.clientX-n.state.mouseX,o=e.clientY-n.state.mouseY;n.setState({mouseX:e.clientX,mouseY:e.clientY}),n.props.onChangeImgState(n.props.width,n.props.height,n.props.top+o,n.props.left+t)}},n.handleMouseUp=function(e){n.setState({isMouseDown:!1})},n.bindEvent=function(e){var t="addEventListener";e&&(t="removeEventListener"),document[t]("click",n.handleMouseUp,!1),document[t]("mousemove",n.handleMouseMove,!1),window[t]("resize",n.handleResize,!1)},n.state={isMouseDown:!1,mouseX:0,mouseY:0},n}return c(t,e),t.prototype.componentDidMount=function(){this.props.drag&&this.bindEvent()},t.prototype.componentDidUpdate=function(e){return this.props.visible&&!e.visible&&this.props.drag?this.bindEvent():!this.props.visible&&e.visible&&(this.handleMouseUp({}),this.props.drag)?this.bindEvent(!0):!this.props.drag&&e.drag?this.bindEvent(!0):this.props.drag&&!e.drag&&this.props.visible?this.bindEvent(!0):void 0},t.prototype.componentWillUnmount=function(){this.bindEvent(!0)},t.prototype.render=function(){var e={width:this.props.width+"px",height:this.props.height+"px",transform:"\ntranslateX("+(null!==this.props.left?this.props.left+"px":"aoto")+") translateY("+this.props.top+"px)\n rotate("+this.props.rotate+"deg) scaleX("+this.props.scaleX+") scaleY("+this.props.scaleY+")"},t=(0,v.default)(this.props.prefixCls+"-image",a({drag:this.props.drag},this.props.prefixCls+"-image-transition",!this.state.isMouseDown)),n={zIndex:this.props.zIndex},o=null;return""!==this.props.imgSrc&&(o=u.createElement("img",{className:t,src:this.props.imgSrc,style:e,onMouseDown:this.handleMouseDown})),this.props.loading&&(o=u.createElement("div",{style:{display:"flex",height:window.innerHeight-84+"px",justifyContent:"center",alignItems:"center"}},u.createElement(f.default,null))),u.createElement("div",{className:this.props.prefixCls+"-canvas",onMouseDown:this.handleCanvasMouseDown,style:n},o)},t}(u.Component);t.default=y,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}function p(){}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var u=function(){function e(e,t){var n=[],o=!0,i=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{!o&&s.return&&s.return()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=n(1),f=i(h);n(11);var d=n(6),v=o(d),y=n(8),m=o(y),g=n(9),b=o(g),w=n(2),O=o(w),C=n(10),x=i(C),I=n(3),E=o(I),T=300,j=function(e){function t(n){s(this,t);var o=l(this,e.call(this,n));return o.handleClose=function(){o.props.onClose()},o.loadImgSuccess=function(e,t,n,i){var r=t,a=n;o.props.defaultSize&&(r=o.props.defaultSize.width,a=o.props.defaultSize.height),e.defaultSize&&(r=e.defaultSize.width,a=e.defaultSize.height);var s=o.getImgWidthHeight(r,a),l=u(s,2),c=l[0],p=l[1],h=(o.containerWidth-c)/2,f=(o.containerHeight-p-o.footerHeight)/2,d=o.props.defaultScale,v=o.props.defaultScale;o.props.noResetZoomAfterChange&&i&&(d=o.state.scaleX,v=o.state.scaleY),o.setState({width:c,height:p,left:h,top:f,imageWidth:t,imageHeight:n,loading:!1,rotate:0,scaleX:d,scaleY:v})},o.handleChangeImg=function(e){if((o.props.loop||!(e>=o.props.images.length||e<0))&&(e>=o.props.images.length&&(e=0),e<0&&(e=o.props.images.length-1),e!==o.state.activeIndex)){if(o.props.onChange){var t=o.getActiveImage(e);o.props.onChange(t,e)}o.loadImg(e,!0)}},o.handleChangeImgState=function(e,t,n,i){o.setState({width:e,height:t,top:n,left:i})},o.handleDefaultAction=function(e){switch(e){case w.ActionType.prev:o.handleChangeImg(o.state.activeIndex-1);break;case w.ActionType.next:o.handleChangeImg(o.state.activeIndex+1);break;case w.ActionType.zoomIn:var t=o.getImageCenterXY();o.handleZoom(t.x,t.y,1,o.props.zoomSpeed);break;case w.ActionType.zoomOut:var n=o.getImageCenterXY();o.handleZoom(n.x,n.y,-1,o.props.zoomSpeed);break;case w.ActionType.rotateLeft:o.handleRotate();break;case w.ActionType.rotateRight:o.handleRotate(!0);break;case w.ActionType.reset:o.loadImg(o.state.activeIndex);break;case w.ActionType.scaleX:o.handleScaleX(-1);break;case w.ActionType.scaleY:o.handleScaleY(-1);break;case w.ActionType.download:o.handleDownload()}},o.handleAction=function(e){if(o.handleDefaultAction(e.actionType),e.onClick){var t=o.getActiveImage();e.onClick(t)}},o.handleDownload=function(){var e=o.getActiveImage();e.downloadUrl&&(location.href=e.downloadUrl)},o.handleScaleX=function(e){o.setState({scaleX:o.state.scaleX*e})},o.handleScaleY=function(e){o.setState({scaleY:o.state.scaleY*e})},o.handleScrollZoom=function(e,t,n){o.handleZoom(e,t,n,o.props.zoomSpeed)},o.handleZoom=function(e,t,n,i){var r=o.getImageCenterXY(),a=e-r.x,s=t-r.y,l=0,c=0,p=0,h=0,f=0,d=0;if(0===o.state.width){var v=o.getImgWidthHeight(o.state.imageWidth,o.state.imageHeight),y=u(v,2),m=y[0],g=y[1];c=(o.containerWidth-m)/2,l=(o.containerHeight-o.footerHeight-g)/2,p=o.state.width+m,h=o.state.height+g,f=d=1}else{var b=o.state.scaleX>0?1:-1,w=o.state.scaleY>0?1:-1;if(f=o.state.scaleX+i*n*b,d=o.state.scaleY+i*n*w,Math.abs(f)<.1||Math.abs(d)<.1)return;l=o.state.top+-n*s/o.state.scaleX*i*b,c=o.state.left+-n*a/o.state.scaleY*i*w,p=o.state.width,h=o.state.height}o.setState({width:p,scaleX:f,scaleY:d,height:h,top:l,left:c,loading:!1})},o.getImageCenterXY=function(){return{x:o.state.left+o.state.width/2,y:o.state.top+o.state.height/2}},o.handleRotate=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];o.setState({rotate:o.state.rotate+90*(e?1:-1)})},o.handleResize=function(){if(o.setContainerWidthHeight(),o.props.visible){var e=(o.containerWidth-o.state.width)/2,t=(o.containerHeight-o.state.height-o.footerHeight)/2;o.setState({left:e,top:t})}},o.handleKeydown=function(e){var t=e.keyCode||e.which||e.charCode,n=!1;switch(t){case 27:o.props.onClose(),n=!0;break;case 37:e.ctrlKey?o.handleDefaultAction(w.ActionType.rotateLeft):o.handleDefaultAction(w.ActionType.prev),n=!0;break;case 39:e.ctrlKey?o.handleDefaultAction(w.ActionType.rotateRight):o.handleDefaultAction(w.ActionType.next),n=!0;break;case 38:o.handleDefaultAction(w.ActionType.zoomIn),n=!0;break;case 40:o.handleDefaultAction(w.ActionType.zoomOut),n=!0;break;case 49:e.ctrlKey&&(o.loadImg(o.state.activeIndex),n=!0)}n&&e.preventDefault()},o.handleTransitionEnd=function(){o.state.transitionEnd&&!o.state.visibleStart||o.setState({visibleStart:!1,transitionEnd:!0})},o.handleCanvasMouseDown=function(e){o.props.onMaskClick(e)},o.getActiveImage=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t={src:"",alt:"",downloadUrl:""},n=o.props.images||[],i=null;return i=void 0!==e?e:o.state.activeIndex,n.length>0&&i>=0&&(t=n[i]),t},o.handleMouseScroll=function(e){if(!o.props.disableMouseZoom){e.preventDefault();var t=0,n=e.deltaY;if(t=0===n?0:n>0?-1:1,0!==t){var i=e.clientX,r=e.clientY;if(o.props.container){var a=o.props.container.getBoundingClientRect();i-=a.left,r-=a.top}o.handleScrollZoom(i,r,t)}}},o.prefixCls="react-viewer",o.state={visible:!1,visibleStart:!1,transitionEnd:!1,activeIndex:o.props.activeIndex,width:0,height:0,top:15,left:null,rotate:0,imageWidth:0,imageHeight:0,scaleX:o.props.defaultScale,scaleY:o.props.defaultScale,loading:!1,loadFailed:!1},o.setContainerWidthHeight(),o.footerHeight=x.FOOTER_HEIGHT,o}return c(t,e),t.prototype.setContainerWidthHeight=function(){this.containerWidth=window.innerWidth,this.containerHeight=window.innerHeight,this.props.container&&(this.containerWidth=this.props.container.offsetWidth,this.containerHeight=this.props.container.offsetHeight,this.setInlineContainerHeight())},t.prototype.setInlineContainerHeight=function(){var e=this.refs.viewerCore;e&&(this.containerHeight=e.offsetHeight)},t.prototype.startVisible=function(e){var t=this;this.props.container||(document.body.style.overflow="hidden",document.body.scrollHeight>document.body.clientHeight&&(document.body.style.paddingRight="15px")),this.setState({visibleStart:!0}),setTimeout(function(){t.setState({visible:!0,activeIndex:e}),setTimeout(function(){t.bindEvent(),t.loadImg(e)},300)},10)},t.prototype.componentDidMount=function(){var e=this.refs.viewerCore;e.addEventListener("transitionend",this.handleTransitionEnd,!1),this.refs.viewerCore.addEventListener("wheel",this.handleMouseScroll,!1),0===this.containerHeight&&this.setInlineContainerHeight(),this.startVisible(this.state.activeIndex)},t.prototype.getImgWidthHeight=function(e,t){var n=0,o=0,i=.8*this.containerWidth,r=.8*(this.containerHeight-this.footerHeight);return n=Math.min(i,e),o=n/e*t,o>r&&(o=r,n=o/t*e),this.props.noLimitInitializationSize&&(n=e,o=t),[n,o]},t.prototype.loadImg=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=null,i=this.props.images||[];i.length>0&&(o=i[e]);var r=!1,a=new Image;this.setState({activeIndex:e,loading:!0,loadFailed:!1},function(){a.onload=function(){r||t.loadImgSuccess(o,a.width,a.height,n)},a.onerror=function(){if(t.props.defaultImg){t.setState({loadFailed:!0});var i=t.props.defaultImg.width||.5*t.containerWidth,r=t.props.defaultImg.height||.5*t.containerHeight;t.loadImgSuccess(o,i,r,n)}else t.setState({activeIndex:e,imageWidth:0,imageHeight:0,loading:!1})},a.src=o.src,a.complete&&(r=!0,t.loadImgSuccess(o,a.width,a.height,n))})},t.prototype.bindEvent=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="addEventListener";e&&(t="removeEventListener"),this.props.disableKeyboardSupport||document[t]("keydown",this.handleKeydown,!1)},t.prototype.componentWillUnmount=function(){this.bindEvent(!0),this.refs.viewerCore.removeEventListener("transitionend",this.handleTransitionEnd,!1)},t.prototype.componentDidUpdate=function(e){var t=this;return this.props.visible&&!e.visible?void this.startVisible(this.props.activeIndex):!this.props.visible&&e.visible?(this.bindEvent(!0),this.handleZoom(this.containerWidth/2,(this.containerHeight-this.footerHeight)/2,-1,(this.state.scaleX>0?1:-1)*this.state.scaleX-.11),void setTimeout(function(){document.body.style.overflow="",document.body.style.paddingRight="",t.setState({visible:!1,transitionEnd:!1,width:0,height:0,scaleX:t.props.defaultScale,scaleY:t.props.defaultScale,rotate:1,imageWidth:0,imageHeight:0,loadFailed:!1})},T)):this.props.activeIndex!==e.activeIndex?void this.handleChangeImg(this.props.activeIndex):void 0},t.prototype.render=function(){var e,t={src:"",alt:""},n=1e3;this.props.zIndex&&(n=this.props.zIndex);var o={opacity:this.state.visible?1:0};!this.state.visible&&this.state.transitionEnd&&(o.display="none"),!this.state.visible&&this.state.visibleStart&&(o.display="block"),this.state.visible&&this.state.transitionEnd&&(t=this.getActiveImage());var i=(0,E.default)(""+this.prefixCls,this.prefixCls+"-transition",(e={},a(e,this.prefixCls+"-inline",this.props.container),a(e,this.props.className,this.props.className),e));return f.createElement("div",{ref:"viewerCore",className:i,style:o},f.createElement("div",{className:this.prefixCls+"-mask",style:{zIndex:n}}),this.props.noClose||f.createElement("div",{className:this.prefixCls+"-close "+this.prefixCls+"-btn",onClick:this.handleClose,style:{zIndex:n+10}},f.createElement(O.default,{type:w.ActionType.close})),f.createElement(v.default,{prefixCls:this.prefixCls,imgSrc:this.state.loadFailed?this.props.defaultImg.src||t.src:t.src,visible:this.props.visible,width:this.state.width,height:this.state.height,top:this.state.top,left:this.state.left,rotate:this.state.rotate,onChangeImgState:this.handleChangeImgState,onResize:this.handleResize,zIndex:n+5,scaleX:this.state.scaleX,scaleY:this.state.scaleY,loading:this.state.loading,drag:this.props.drag,container:this.props.container,onCanvasMouseDown:this.handleCanvasMouseDown}),this.props.noFooter||f.createElement("div",{className:this.prefixCls+"-footer",style:{zIndex:n+5}},this.props.noToolbar||f.createElement(b.default,{prefixCls:this.prefixCls,onAction:this.handleAction,alt:t.alt,width:this.state.imageWidth,height:this.state.imageHeight,attribute:this.props.attribute,zoomable:this.props.zoomable,rotatable:this.props.rotatable,scalable:this.props.scalable,changeable:this.props.changeable,downloadable:this.props.downloadable,noImgDetails:this.props.noImgDetails,toolbars:this.props.customToolbar(g.defaultToolbars)}),this.props.noNavbar||f.createElement(m.default,{prefixCls:this.prefixCls,images:this.props.images,activeIndex:this.state.activeIndex,onChangeImg:this.handleChangeImg})))},t}(f.Component);t.default=j,j.defaultProps={visible:!1,onClose:p,images:[],activeIndex:0,zIndex:1e3,drag:!0,attribute:!0,zoomable:!0,rotatable:!0,scalable:!0,onMaskClick:p,changeable:!0,customToolbar:function(e){return e},zoomSpeed:.05,disableKeyboardSupport:!1,noResetZoomAfterChange:!1,noLimitInitializationSize:!1,defaultScale:1,loop:!0,disableMouseZoom:!1},e.exports=t.default},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):i(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=n(1),c=o(l),p=function(e){function t(){r(this,t);var n=a(this,e.apply(this,arguments));return n.handleChangeImg=function(e){n.props.activeIndex!==e&&n.props.onChangeImg(e)},n}return s(t,e),t.prototype.render=function(){var e=this,t="calc(50% - "+(this.props.activeIndex+1)+" * 31px)",n={marginLeft:t};return c.createElement("div",{className:this.props.prefixCls+"-navbar"},c.createElement("ul",{className:this.props.prefixCls+"-list "+this.props.prefixCls+"-list-transition",style:n},this.props.images.map(function(t,n){return c.createElement("li",{key:n,className:n===e.props.activeIndex?"active":"",onClick:function(){e.handleChangeImg(n)}},c.createElement("img",{src:t.src,alt:t.alt}))})))},t}(c.Component);t.default=p,p.defaultProps={activeIndex:0},e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}function c(e,t){var n=e.filter(function(e){return t.indexOf(e.key)<0});return n}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.defaultToolbars=void 0;var p=n(1),u=i(p),h=n(2),f=o(h),d=(t.defaultToolbars=[{key:"zoomIn",actionType:h.ActionType.zoomIn},{key:"zoomOut",actionType:h.ActionType.zoomOut},{key:"prev",actionType:h.ActionType.prev},{key:"reset",actionType:h.ActionType.reset},{key:"next",actionType:h.ActionType.next},{key:"rotateLeft",actionType:h.ActionType.rotateLeft},{key:"rotateRight",actionType:h.ActionType.rotateRight},{key:"scaleX",actionType:h.ActionType.scaleX},{key:"scaleY",actionType:h.ActionType.scaleY},{key:"download",actionType:h.ActionType.download}],function(e){function t(){a(this,t);var n=s(this,e.call(this));return n.renderAction=function(e){var t=null;return"undefined"!=typeof h.ActionType[e.actionType]&&(t=u.createElement(f.default,{type:e.actionType})),e.render&&(t=e.render),u.createElement("li",{key:e.key,className:n.props.prefixCls+"-btn",onClick:function(){n.handleAction(e)},"data-key":e.key},t)},n}return l(t,e),t.prototype.handleAction=function(e){this.props.onAction(e)},t.prototype.render=function(){var e=this,t=this.props.attribute?u.createElement("p",{className:this.props.prefixCls+"-attribute"},this.props.alt&&""+this.props.alt,this.props.noImgDetails||u.createElement("span",{className:this.props.prefixCls+"-img-details"},"("+this.props.width+" x "+this.props.height+")")):null,n=this.props.toolbars;return this.props.zoomable||(n=c(n,["zoomIn","zoomOut"])),this.props.changeable||(n=c(n,["prev","next"])),this.props.rotatable||(n=c(n,["rotateLeft","rotateRight"])),this.props.scalable||(n=c(n,["scaleX","scaleY"])),this.props.downloadable||(n=c(n,["download"])),u.createElement("div",null,t,u.createElement("ul",{className:this.props.prefixCls+"-toolbar"},n.map(function(t){return e.renderAction(t)})))},t}(u.Component));t.default=d},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=84;t.FOOTER_HEIGHT=n},function(e,t){},function(e,n){e.exports=t}])});
!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)&&o.length){var a=n.apply(null,o);a&&e.push(a)}else if("object"===i)for(var s in o)r.call(o,s)&&o[s]&&e.push(s)}}return e.join(" ")}var r={}.hasOwnProperty;"undefined"!=typeof e&&e.exports?(n.default=n,e.exports=n):(o=[],i=function(){return n}.apply(t,o),!(void 0!==i&&(e.exports=i)))}()},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):i(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=n(1),c=o(l),p=function(e){function t(){return r(this,t),a(this,e.call(this))}return s(t,e),t.prototype.render=function(){var e="circle-loading";return c.createElement("div",{className:"loading-wrap",style:this.props.style},c.createElement("div",{className:e}))},t}(c.Component);t.default=p,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var c=n(1),p=i(c),u=n(12),h=i(u),f=n(7),d=o(f),v=function(e){function t(){a(this,t);var n=s(this,e.call(this));return n.container=null,n.defaultContainer=null,"undefined"!=typeof document&&n.setDefaultContainer(),n.component=null,n}return l(t,e),t.prototype.setDefaultContainer=function(){this.defaultContainer=document.createElement("div")},t.prototype.renderViewer=function(){if(this.props.visible||this.component){this.container||(this.props.container?this.container=this.props.container:(this.defaultContainer||this.setDefaultContainer(),this.container=this.defaultContainer,document.body.appendChild(this.container)));var e=this;h.unstable_renderSubtreeIntoContainer(this,p.createElement(d.default,this.props),this.container,function(){e.component=this})}},t.prototype.removeViewer=function(){if(this.container){var e=this.container;h.unmountComponentAtNode(e),e.parentNode.removeChild(e),this.container=null,this.component=null}},t.prototype.componentWillUnmount=function(){this.props.visible&&this.props.onClose&&this.props.onClose(),this.removeViewer()},t.prototype.componentDidMount=function(){this.renderViewer()},t.prototype.componentDidUpdate=function(e){this.props.container!==e.container&&(this.component=null,this.props.container?(this.container&&!e.container&&document.body.removeChild(this.container),this.container=this.props.container):(this.container=this.defaultContainer,document.body.appendChild(this.container))),this.renderViewer()},t.prototype.render=function(){return null},t}(p.Component);t.default=v,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var p=n(1),u=i(p),h=n(4),f=o(h),d=n(3),v=o(d),y=function(e){function t(){s(this,t);var n=l(this,e.call(this));return n.handleResize=function(e){n.props.onResize()},n.handleCanvasMouseDown=function(e){n.props.onCanvasMouseDown(e),n.handleMouseDown(e)},n.handleMouseDown=function(e){0===e.button&&n.props.visible&&n.props.drag&&(e.preventDefault(),e.stopPropagation(),n.setState({isMouseDown:!0,mouseX:e.nativeEvent.clientX,mouseY:e.nativeEvent.clientY}))},n.handleMouseMove=function(e){if(n.state.isMouseDown){var t=e.clientX-n.state.mouseX,o=e.clientY-n.state.mouseY;n.setState({mouseX:e.clientX,mouseY:e.clientY}),n.props.onChangeImgState(n.props.width,n.props.height,n.props.top+o,n.props.left+t)}},n.handleMouseUp=function(e){n.setState({isMouseDown:!1})},n.bindEvent=function(e){var t="addEventListener";e&&(t="removeEventListener"),document[t]("click",n.handleMouseUp,!1),document[t]("mousemove",n.handleMouseMove,!1),window[t]("resize",n.handleResize,!1)},n.state={isMouseDown:!1,mouseX:0,mouseY:0},n}return c(t,e),t.prototype.componentDidMount=function(){this.props.drag&&this.bindEvent()},t.prototype.componentDidUpdate=function(e){return this.props.visible&&!e.visible&&this.props.drag?this.bindEvent():!this.props.visible&&e.visible&&(this.handleMouseUp({}),this.props.drag)?this.bindEvent(!0):!this.props.drag&&e.drag?this.bindEvent(!0):this.props.drag&&!e.drag&&this.props.visible?this.bindEvent(!0):void 0},t.prototype.componentWillUnmount=function(){this.bindEvent(!0)},t.prototype.render=function(){var e={width:this.props.width+"px",height:this.props.height+"px",transform:"\ntranslateX("+(null!==this.props.left?this.props.left+"px":"aoto")+") translateY("+this.props.top+"px)\n rotate("+this.props.rotate+"deg) scaleX("+this.props.scaleX+") scaleY("+this.props.scaleY+")"},t=(0,v.default)(this.props.prefixCls+"-image",a({drag:this.props.drag},this.props.prefixCls+"-image-transition",!this.state.isMouseDown)),n={zIndex:this.props.zIndex},o=null;return""!==this.props.imgSrc&&(o=u.createElement("img",{className:t,src:this.props.imgSrc,style:e,onMouseDown:this.handleMouseDown})),this.props.loading&&(o=u.createElement("div",{style:{display:"flex",height:window.innerHeight-84+"px",justifyContent:"center",alignItems:"center"}},u.createElement(f.default,null))),u.createElement("div",{className:this.props.prefixCls+"-canvas",onMouseDown:this.handleCanvasMouseDown,style:n},o)},t}(u.Component);t.default=y,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}function p(){}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var u=function(){function e(e,t){var n=[],o=!0,i=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{!o&&s.return&&s.return()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=n(1),f=i(h);n(11);var d=n(6),v=o(d),y=n(8),m=o(y),g=n(9),b=o(g),w=n(2),O=o(w),C=n(10),x=i(C),I=n(3),E=o(I),T=300,j=function(e){function t(n){s(this,t);var o=l(this,e.call(this,n));return o.handleClose=function(){o.props.onClose()},o.loadImgSuccess=function(e,t,n,i){var r=t,a=n;o.props.defaultSize&&(r=o.props.defaultSize.width,a=o.props.defaultSize.height),e.defaultSize&&(r=e.defaultSize.width,a=e.defaultSize.height);var s=o.getImgWidthHeight(r,a),l=u(s,2),c=l[0],p=l[1],h=(o.containerWidth-c)/2,f=(o.containerHeight-p-o.footerHeight)/2,d=o.props.defaultScale,v=o.props.defaultScale;o.props.noResetZoomAfterChange&&i&&(d=o.state.scaleX,v=o.state.scaleY),o.setState({width:c,height:p,left:h,top:f,imageWidth:t,imageHeight:n,loading:!1,rotate:0,scaleX:d,scaleY:v})},o.handleChangeImg=function(e){if((o.props.loop||!(e>=o.props.images.length||e<0))&&(e>=o.props.images.length&&(e=0),e<0&&(e=o.props.images.length-1),e!==o.state.activeIndex)){if(o.props.onChange){var t=o.getActiveImage(e);o.props.onChange(t,e)}o.loadImg(e,!0)}},o.handleChangeImgState=function(e,t,n,i){o.setState({width:e,height:t,top:n,left:i})},o.handleDefaultAction=function(e){switch(e){case w.ActionType.prev:o.handleChangeImg(o.state.activeIndex-1);break;case w.ActionType.next:o.handleChangeImg(o.state.activeIndex+1);break;case w.ActionType.zoomIn:var t=o.getImageCenterXY();o.handleZoom(t.x,t.y,1,o.props.zoomSpeed);break;case w.ActionType.zoomOut:var n=o.getImageCenterXY();o.handleZoom(n.x,n.y,-1,o.props.zoomSpeed);break;case w.ActionType.rotateLeft:o.handleRotate();break;case w.ActionType.rotateRight:o.handleRotate(!0);break;case w.ActionType.reset:o.loadImg(o.state.activeIndex);break;case w.ActionType.scaleX:o.handleScaleX(-1);break;case w.ActionType.scaleY:o.handleScaleY(-1);break;case w.ActionType.download:o.handleDownload()}},o.handleAction=function(e){if(o.handleDefaultAction(e.actionType),e.onClick){var t=o.getActiveImage();e.onClick(t)}},o.handleDownload=function(){var e=o.getActiveImage();e.downloadUrl&&(location.href=e.downloadUrl)},o.handleScaleX=function(e){o.setState({scaleX:o.state.scaleX*e})},o.handleScaleY=function(e){o.setState({scaleY:o.state.scaleY*e})},o.handleScrollZoom=function(e,t,n){o.handleZoom(e,t,n,o.props.zoomSpeed)},o.handleZoom=function(e,t,n,i){var r=o.getImageCenterXY(),a=e-r.x,s=t-r.y,l=0,c=0,p=0,h=0,f=0,d=0;if(0===o.state.width){var v=o.getImgWidthHeight(o.state.imageWidth,o.state.imageHeight),y=u(v,2),m=y[0],g=y[1];c=(o.containerWidth-m)/2,l=(o.containerHeight-o.footerHeight-g)/2,p=o.state.width+m,h=o.state.height+g,f=d=1}else{var b=o.state.scaleX>0?1:-1,w=o.state.scaleY>0?1:-1;if(f=o.state.scaleX+i*n*b,d=o.state.scaleY+i*n*w,Math.abs(f)<.1||Math.abs(d)<.1)return;l=o.state.top+-n*s/o.state.scaleX*i*b,c=o.state.left+-n*a/o.state.scaleY*i*w,p=o.state.width,h=o.state.height}o.setState({width:p,scaleX:f,scaleY:d,height:h,top:l,left:c,loading:!1})},o.getImageCenterXY=function(){return{x:o.state.left+o.state.width/2,y:o.state.top+o.state.height/2}},o.handleRotate=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];o.setState({rotate:o.state.rotate+90*(e?1:-1)})},o.handleResize=function(){if(o.setContainerWidthHeight(),o.props.visible){var e=(o.containerWidth-o.state.width)/2,t=(o.containerHeight-o.state.height-o.footerHeight)/2;o.setState({left:e,top:t})}},o.handleKeydown=function(e){var t=e.keyCode||e.which||e.charCode,n=!1;switch(t){case 27:o.props.onClose(),n=!0;break;case 37:e.ctrlKey?o.handleDefaultAction(w.ActionType.rotateLeft):o.handleDefaultAction(w.ActionType.prev),n=!0;break;case 39:e.ctrlKey?o.handleDefaultAction(w.ActionType.rotateRight):o.handleDefaultAction(w.ActionType.next),n=!0;break;case 38:o.handleDefaultAction(w.ActionType.zoomIn),n=!0;break;case 40:o.handleDefaultAction(w.ActionType.zoomOut),n=!0;break;case 49:e.ctrlKey&&(o.loadImg(o.state.activeIndex),n=!0)}n&&(e.preventDefault(),e.stopPropagation())},o.handleTransitionEnd=function(){o.state.transitionEnd&&!o.state.visibleStart||o.setState({visibleStart:!1,transitionEnd:!0})},o.handleCanvasMouseDown=function(e){o.props.onMaskClick(e)},o.getActiveImage=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t={src:"",alt:"",downloadUrl:""},n=o.props.images||[],i=null;return i=void 0!==e?e:o.state.activeIndex,n.length>0&&i>=0&&(t=n[i]),t},o.handleMouseScroll=function(e){if(!o.props.disableMouseZoom){e.preventDefault();var t=0,n=e.deltaY;if(t=0===n?0:n>0?-1:1,0!==t){var i=e.clientX,r=e.clientY;if(o.props.container){var a=o.props.container.getBoundingClientRect();i-=a.left,r-=a.top}o.handleScrollZoom(i,r,t)}}},o.prefixCls="react-viewer",o.state={visible:!1,visibleStart:!1,transitionEnd:!1,activeIndex:o.props.activeIndex,width:0,height:0,top:15,left:null,rotate:0,imageWidth:0,imageHeight:0,scaleX:o.props.defaultScale,scaleY:o.props.defaultScale,loading:!1,loadFailed:!1},o.setContainerWidthHeight(),o.footerHeight=x.FOOTER_HEIGHT,o}return c(t,e),t.prototype.setContainerWidthHeight=function(){this.containerWidth=window.innerWidth,this.containerHeight=window.innerHeight,this.props.container&&(this.containerWidth=this.props.container.offsetWidth,this.containerHeight=this.props.container.offsetHeight,this.setInlineContainerHeight())},t.prototype.setInlineContainerHeight=function(){var e=this.refs.viewerCore;e&&(this.containerHeight=e.offsetHeight)},t.prototype.startVisible=function(e){var t=this;this.props.container||(document.body.style.overflow="hidden",document.body.scrollHeight>document.body.clientHeight&&(document.body.style.paddingRight="15px")),this.setState({visibleStart:!0}),setTimeout(function(){t.setState({visible:!0,activeIndex:e}),setTimeout(function(){t.bindEvent(),t.loadImg(e)},300)},10)},t.prototype.componentDidMount=function(){var e=this.refs.viewerCore;e.addEventListener("transitionend",this.handleTransitionEnd,!1),this.refs.viewerCore.addEventListener("wheel",this.handleMouseScroll,!1),0===this.containerHeight&&this.setInlineContainerHeight(),this.startVisible(this.state.activeIndex)},t.prototype.getImgWidthHeight=function(e,t){var n=0,o=0,i=.8*this.containerWidth,r=.8*(this.containerHeight-this.footerHeight);return n=Math.min(i,e),o=n/e*t,o>r&&(o=r,n=o/t*e),this.props.noLimitInitializationSize&&(n=e,o=t),[n,o]},t.prototype.loadImg=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=null,i=this.props.images||[];i.length>0&&(o=i[e]);var r=!1,a=new Image;this.setState({activeIndex:e,loading:!0,loadFailed:!1},function(){a.onload=function(){r||t.loadImgSuccess(o,a.width,a.height,n)},a.onerror=function(){if(t.props.defaultImg){t.setState({loadFailed:!0});var i=t.props.defaultImg.width||.5*t.containerWidth,r=t.props.defaultImg.height||.5*t.containerHeight;t.loadImgSuccess(o,i,r,n)}else t.setState({activeIndex:e,imageWidth:0,imageHeight:0,loading:!1})},a.src=o.src,a.complete&&(r=!0,t.loadImgSuccess(o,a.width,a.height,n))})},t.prototype.bindEvent=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="addEventListener";e&&(t="removeEventListener"),this.props.disableKeyboardSupport||document[t]("keydown",this.handleKeydown,!0)},t.prototype.componentWillUnmount=function(){this.bindEvent(!0),this.refs.viewerCore.removeEventListener("transitionend",this.handleTransitionEnd,!1)},t.prototype.componentDidUpdate=function(e){var t=this;return this.props.visible&&!e.visible?void this.startVisible(this.props.activeIndex):!this.props.visible&&e.visible?(this.bindEvent(!0),this.handleZoom(this.containerWidth/2,(this.containerHeight-this.footerHeight)/2,-1,(this.state.scaleX>0?1:-1)*this.state.scaleX-.11),void setTimeout(function(){document.body.style.overflow="",document.body.style.paddingRight="",t.setState({visible:!1,transitionEnd:!1,width:0,height:0,scaleX:t.props.defaultScale,scaleY:t.props.defaultScale,rotate:1,imageWidth:0,imageHeight:0,loadFailed:!1})},T)):this.props.activeIndex!==e.activeIndex?void this.handleChangeImg(this.props.activeIndex):void 0},t.prototype.render=function(){var e,t={src:"",alt:""},n=1e3;this.props.zIndex&&(n=this.props.zIndex);var o={opacity:this.state.visible?1:0};!this.state.visible&&this.state.transitionEnd&&(o.display="none"),!this.state.visible&&this.state.visibleStart&&(o.display="block"),this.state.visible&&this.state.transitionEnd&&(t=this.getActiveImage());var i=(0,E.default)(""+this.prefixCls,this.prefixCls+"-transition",(e={},a(e,this.prefixCls+"-inline",this.props.container),a(e,this.props.className,this.props.className),e));return f.createElement("div",{ref:"viewerCore",className:i,style:o},f.createElement("div",{className:this.prefixCls+"-mask",style:{zIndex:n}}),this.props.noClose||f.createElement("div",{className:this.prefixCls+"-close "+this.prefixCls+"-btn",onClick:this.handleClose,style:{zIndex:n+10}},f.createElement(O.default,{type:w.ActionType.close})),f.createElement(v.default,{prefixCls:this.prefixCls,imgSrc:this.state.loadFailed?this.props.defaultImg.src||t.src:t.src,visible:this.props.visible,width:this.state.width,height:this.state.height,top:this.state.top,left:this.state.left,rotate:this.state.rotate,onChangeImgState:this.handleChangeImgState,onResize:this.handleResize,zIndex:n+5,scaleX:this.state.scaleX,scaleY:this.state.scaleY,loading:this.state.loading,drag:this.props.drag,container:this.props.container,onCanvasMouseDown:this.handleCanvasMouseDown}),this.props.noFooter||f.createElement("div",{className:this.prefixCls+"-footer",style:{zIndex:n+5}},this.props.noToolbar||f.createElement(b.default,{prefixCls:this.prefixCls,onAction:this.handleAction,alt:t.alt,width:this.state.imageWidth,height:this.state.imageHeight,attribute:this.props.attribute,zoomable:this.props.zoomable,rotatable:this.props.rotatable,scalable:this.props.scalable,changeable:this.props.changeable,downloadable:this.props.downloadable,noImgDetails:this.props.noImgDetails,toolbars:this.props.customToolbar(g.defaultToolbars)}),this.props.noNavbar||f.createElement(m.default,{prefixCls:this.prefixCls,images:this.props.images,activeIndex:this.state.activeIndex,onChangeImg:this.handleChangeImg})))},t}(f.Component);t.default=j,j.defaultProps={visible:!1,onClose:p,images:[],activeIndex:0,zIndex:1e3,drag:!0,attribute:!0,zoomable:!0,rotatable:!0,scalable:!0,onMaskClick:p,changeable:!0,customToolbar:function(e){return e},zoomSpeed:.05,disableKeyboardSupport:!1,noResetZoomAfterChange:!1,noLimitInitializationSize:!1,defaultScale:1,loop:!0,disableMouseZoom:!1},e.exports=t.default},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):i(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=n(1),c=o(l),p=function(e){function t(){r(this,t);var n=a(this,e.apply(this,arguments));return n.handleChangeImg=function(e){n.props.activeIndex!==e&&n.props.onChangeImg(e)},n}return s(t,e),t.prototype.render=function(){var e=this,t="calc(50% - "+(this.props.activeIndex+1)+" * 31px)",n={marginLeft:t};return c.createElement("div",{className:this.props.prefixCls+"-navbar"},c.createElement("ul",{className:this.props.prefixCls+"-list "+this.props.prefixCls+"-list-transition",style:n},this.props.images.map(function(t,n){return c.createElement("li",{key:n,className:n===e.props.activeIndex?"active":"",onClick:function(){e.handleChangeImg(n)}},c.createElement("img",{src:t.src,alt:t.alt}))})))},t}(c.Component);t.default=p,p.defaultProps={activeIndex:0},e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e,t){for(var n=Object.getOwnPropertyNames(t),o=0;o<n.length;o++){var i=n[o],r=Object.getOwnPropertyDescriptor(t,i);r&&r.configurable&&void 0===e[i]&&Object.defineProperty(e,i,r)}return e}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):r(e,t))}function c(e,t){var n=e.filter(function(e){return t.indexOf(e.key)<0});return n}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.defaultToolbars=void 0;var p=n(1),u=i(p),h=n(2),f=o(h),d=(t.defaultToolbars=[{key:"zoomIn",actionType:h.ActionType.zoomIn},{key:"zoomOut",actionType:h.ActionType.zoomOut},{key:"prev",actionType:h.ActionType.prev},{key:"reset",actionType:h.ActionType.reset},{key:"next",actionType:h.ActionType.next},{key:"rotateLeft",actionType:h.ActionType.rotateLeft},{key:"rotateRight",actionType:h.ActionType.rotateRight},{key:"scaleX",actionType:h.ActionType.scaleX},{key:"scaleY",actionType:h.ActionType.scaleY},{key:"download",actionType:h.ActionType.download}],function(e){function t(){a(this,t);var n=s(this,e.call(this));return n.renderAction=function(e){var t=null;return"undefined"!=typeof h.ActionType[e.actionType]&&(t=u.createElement(f.default,{type:e.actionType})),e.render&&(t=e.render),u.createElement("li",{key:e.key,className:n.props.prefixCls+"-btn",onClick:function(){n.handleAction(e)},"data-key":e.key},t)},n}return l(t,e),t.prototype.handleAction=function(e){this.props.onAction(e)},t.prototype.render=function(){var e=this,t=this.props.attribute?u.createElement("p",{className:this.props.prefixCls+"-attribute"},this.props.alt&&""+this.props.alt,this.props.noImgDetails||u.createElement("span",{className:this.props.prefixCls+"-img-details"},"("+this.props.width+" x "+this.props.height+")")):null,n=this.props.toolbars;return this.props.zoomable||(n=c(n,["zoomIn","zoomOut"])),this.props.changeable||(n=c(n,["prev","next"])),this.props.rotatable||(n=c(n,["rotateLeft","rotateRight"])),this.props.scalable||(n=c(n,["scaleX","scaleY"])),this.props.downloadable||(n=c(n,["download"])),u.createElement("div",null,t,u.createElement("ul",{className:this.props.prefixCls+"-toolbar"},n.map(function(t){return e.renderAction(t)})))},t}(u.Component));t.default=d},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=84;t.FOOTER_HEIGHT=n},function(e,t){},function(e,n){e.exports=t}])});

@@ -322,2 +322,3 @@ 'use strict';

e.preventDefault();
e.stopPropagation();
}

@@ -528,3 +529,3 @@ };

if (!this.props.disableKeyboardSupport) {
document[funcName]('keydown', this.handleKeydown, false);
document[funcName]('keydown', this.handleKeydown, true);
}

@@ -531,0 +532,0 @@ };

{
"name": "react-viewer",
"version": "2.11.0",
"version": "2.11.1",
"description": "react image viewer",

@@ -40,3 +40,3 @@ "main": "dist/index",

"@types/react-dom": "^0.14.17",
"antd": "^3.16.2",
"antd": "^3.24.0",
"atool-build": "^1.0.8",

@@ -43,0 +43,0 @@ "babel-jest": "^23.4.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc