From 3dc9d466ae3547b5187fba99efa1b3ef870dd799 Mon Sep 17 00:00:00 2001 From: infeng Date: Mon, 9 Apr 2018 17:27:51 +0800 Subject: [PATCH] refactor: rewrite image download --- README.md | 14 ++++++++------ demo/index.tsx | 8 +++++--- docs/index.html | 2 +- docs/index.js | 6 +++--- src/ViewerCore.tsx | 12 ++++-------- src/ViewerProps.ts | 7 +++---- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 1deb843..09df946 100644 --- a/README.md +++ b/README.md @@ -50,23 +50,25 @@ class App extends React.Component { |-------------|--------------|---------|-----------------------------|----------| | visible | string | false | Viewer visible | true | | onClose | string | - | Specify a function that will be called when Visible close | true | -| images | {src: string, alt: string}[] | [] | image source array | true | +| images | [ImageDecorator](#ImageDecorator)[] | [] | image source array | true | | activeIndex | number | 0 | active image index | false | | zIndex | number | 1000 | Viewer css z-index | false | | container | HTMLElement | null | set parent node(inline mode) | false | | drag | boolean | true | whether to drag image | false | | attribute | boolean | true | whether to show image attribute | false | -| zoomable | boolean | true | whether to show 'zoom' buttom | false | +| zoomable | boolean | true | whether to show 'zoom' button | false | | rotatable | boolean | true | whether to show 'rotate' button | false | | scalable | boolean | true | whether to show 'scale' button | false | -| onMaskClick | (e) => void | - | callback function when mask is clicked | -| download | [Download](#Download) | - | download config | +| onMaskClick | (e) => void | - | callback function when mask is clicked | false | +| download | boolean | false | whether to show 'download' | false | -### Download +### ImageDecorator | props | type | default | description | required | |-------------|--------------|---------|-----------------------------|----------| -| onDownload | function(url: string) | - | callback when download is clicked | true | +| src | string | - | image source | true | +| alt | string | - | image description | false | +| downloadUrl | string | - | image downlaod url | false | ## Keyboard support diff --git a/demo/index.tsx b/demo/index.tsx index 749ea80..44688b5 100644 --- a/demo/index.tsx +++ b/demo/index.tsx @@ -47,15 +47,19 @@ class App extends React.Component> { let images = [{ src: img, alt: 'lake', + downloadUrl: '', }, { src: img2, alt: 'mountain', + downloadUrl: '', }, { src: img3, alt: '', + downloadUrl: '', }, { src: img4, alt: '', + downloadUrl: '', }]; let inline = this.state.mode === 'inline'; @@ -127,9 +131,7 @@ class App extends React.Component> { activeIndex={this.state.activeIndex} attribute={false} container={inline ? this.container : null} - download={{ - onDownload: (url) => { console.log(url); }, - }} + downloadable />
diff --git a/docs/index.html b/docs/index.html index 3cecc95..29ba5a8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1 @@ - react-viewer
\ No newline at end of file + react-viewer
\ No newline at end of file diff --git a/docs/index.js b/docs/index.js index 68ec8de..5ecd6ac 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,4 +1,4 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="/react-viewer/",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,o){r.apply(this,[e,t,o].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){"use strict";function r(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 o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;r0?(0,i.default)({marginLeft:u/-2,marginRight:u/-2},s):s,v=m.Children.map(c,function(e){return e?e.props&&u>0?(0,m.cloneElement)(e,{style:(0,i.default)({paddingLeft:u/2,paddingRight:u/2},e.props.style)}):e:null});return g.default.createElement("div",(0,i.default)({},d,{className:h,style:y}),v)}}]),t}(g.default.Component);t.default=S,S.defaultProps={gutter:0},S.propTypes={type:C.default.string,align:C.default.string,justify:C.default.string,className:C.default.string,children:C.default.node,gutter:C.default.number,prefixCls:C.default.string},e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(7),i=r(o),a=n(13),l=r(a),u=n(1),s=r(u),c=n(8),f=r(c),p=n(59),d=r(p),h=function(e){var t=e.type,n=e.className,r=void 0===n?"":n,o=e.spin,a=(0,f.default)((0,l.default)({anticon:!0,"anticon-spin":!!o||"loading"===t},"anticon-"+t,!0),r);return s.default.createElement("i",(0,i.default)({},(0,d.default)(e,["type","spin"]),{className:a}))};t.default=h,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(42);t.default=r.Row,e.exports=t.default},66,function(e,t,n){"use strict";function r(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 o(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;r0?1:-1:e.detail&&(t=e.detail>0?-1:1),0!==t){var n=e.clientX,r=e.clientY;if(this.props.container){var o=this.props.container.getBoundingClientRect();n-=o.left,r-=o.top}this.props.onZoom(n,r,t,.05)}},t.prototype.bindEvent=function(e){var t="addEventListener";e&&(t="removeEventListener");var n=document;this.props.container&&(n=this.props.container),n[t]("DOMMouseScroll",this.handleMouseScroll,!1),n[t]("mousewheel",this.handleMouseScroll,!1),document[t]("click",this.handleMouseUp,!1),document[t]("mousemove",this.handleMouseMove,!1),window[t]("resize",this.handleResize,!1)},t.prototype.componentWillReceiveProps=function(e){return!this.props.visible&&e.visible&&e.drag?this.bindEvent():this.props.visible&&!e.visible&&(this.handleMouseUp({}),e.drag)?this.bindEvent(!0):this.props.drag&&!e.drag?this.bindEvent(!0):!this.props.drag&&e.drag&&e.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:"translateX("+(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=this.props.drag?"drag":"";this.state.isMouseDown||(t+=" "+this.props.prefixCls+"-image-transition");var n={zIndex:this.props.zIndex},r=null;return""!==this.props.imgSrc&&(r=c.createElement("img",{className:t,src:this.props.imgSrc,style:e,onMouseDown:this.handleMouseDown})),this.props.loading&&(r=c.createElement("div",{style:{display:"flex",height:"100%",justifyContent:"center",alignItems:"center"}},c.createElement(p.default,null))),c.createElement("div",{className:this.props.prefixCls+"-canvas",onMouseDown:this.handleCanvasMouseDown,style:n},r)},t}(c.Component);t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}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),r=0;r0&&r.state.activeIndex>=0&&(e=t[r.state.activeIndex]),e},r.prefixCls="react-viewer",r.state={visible:!1,visibleStart:!1,transitionEnd:!1,activeIndex:r.props.activeIndex,width:0,height:0,top:15,left:null,rotate:0,imageWidth:0,imageHeight:0,scaleX:1,scaleY:1,loading:!1},r.handleChangeImg=r.handleChangeImg.bind(r),r.handleChangeImgState=r.handleChangeImgState.bind(r),r.handleAction=r.handleAction.bind(r),r.handleResize=r.handleResize.bind(r),r.handleZoom=r.handleZoom.bind(r),r.handleRotate=r.handleRotate.bind(r),r.handleKeydown=r.handleKeydown.bind(r),r.handleScaleX=r.handleScaleX.bind(r),r.handleScaleY=r.handleScaleY.bind(r),r.getImageCenterXY=r.getImageCenterXY.bind(r),r.setContainerWidthHeight(),r.footerHeight=84,r}return u(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)},t.prototype.handleClose=function(e){this.props.onClose()},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}),setTimeout(function(){t.bindEvent(),t.loadImg(e,!0)},300)},10)},t.prototype.componentDidMount=function(){this.refs.viewerCore.addEventListener("transitionend",this.handleTransitionEnd,!1),this.startVisible(this.state.activeIndex)},t.prototype.getImgWidthHeight=function(e,t){var n=0,r=0,o=.8*this.containerWidth,i=.8*(this.containerHeight-this.footerHeight);return n=Math.min(o,e),r=n/e*t,r>i&&(r=i,n=r/t*e),[n,r]},t.prototype.loadImg=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="",o=this.props.images||[];o.length>0&&(r=o[e].src);var i=new Image;i.src=r,n?this.setState({activeIndex:e,width:0,height:0,left:0,top:0,rotate:0,scaleX:1,scaleY:1,loading:!0}):this.setState({activeIndex:e,loading:!0}),i.onload=function(){var r=i.width,o=i.height;if(n)setTimeout(function(){t.setState({activeIndex:e,imageWidth:r,imageHeight:o});var n=t.getImageCenterXY();t.handleZoom(n.x,n.y,1,1)},50);else{var a=t.getImgWidthHeight(r,o),l=c(a,2),u=l[0],s=l[1],f=(t.containerWidth-u)/2,p=(t.containerHeight-s-t.footerHeight)/2;t.setState({activeIndex:e,width:u,height:s,left:f,top:p,imageWidth:r,imageHeight:o,loading:!1,rotate:0,scaleX:1,scaleY:1})}},i.onerror=function(){t.setState({activeIndex:e,imageWidth:0,imageHeight:0,loading:!1})}},t.prototype.handleChangeImg=function(e){this.loadImg(e)},t.prototype.handleChangeImgState=function(e,t,n,r){this.setState({width:e,height:t,top:n,left:r})},t.prototype.handleAction=function(e){switch(e){case b.ActionType.prev:this.state.activeIndex-1>=0&&this.handleChangeImg(this.state.activeIndex-1);break;case b.ActionType.next:this.state.activeIndex+10?1:-1,x=this.state.scaleY>0?1:-1;if(d=this.state.scaleX+r*n*b,h=this.state.scaleY+r*n*x,Math.abs(d)<.1||Math.abs(h)<.1)return;u=this.state.top+-n*a/this.state.scaleX*r*b,s=this.state.left+-n*i/this.state.scaleY*r*x,f=this.state.width,p=this.state.height}this.setState({width:f,scaleX:d,scaleY:h,height:p,top:u,left:s,loading:!1})},t.prototype.getImageCenterXY=function(){return{x:this.state.left+this.state.width/2,y:this.state.top+this.state.height/2}},t.prototype.handleRotate=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.setState({rotate:this.state.rotate+90*(e?1:-1)})},t.prototype.handleResize=function(){if(this.setContainerWidthHeight(),this.props.visible){var e=this.getImgWidthHeight(this.state.imageWidth,this.state.imageHeight),t=c(e,2),n=t[0],r=t[1],o=(this.containerWidth-n)/2,i=(this.containerHeight-r-this.footerHeight)/2;this.setState({width:n,height:r,left:o,top:i,rotate:0,scaleX:1,scaleY:1})}},t.prototype.handleKeydown=function(e){var t=e.keyCode||e.which||e.charCode,n=!1;switch(t){case 27:this.props.onClose(),n=!0;break;case 37:e.ctrlKey?this.handleAction(b.ActionType.rotateLeft):this.handleAction(b.ActionType.prev),n=!0;break;case 39:e.ctrlKey?this.handleAction(b.ActionType.rotateRight):this.handleAction(b.ActionType.next),n=!0;break;case 38:this.handleAction(b.ActionType.zoomIn),n=!0;break;case 40:this.handleAction(b.ActionType.zoomOut),n=!0;break;case 49:e.ctrlKey&&(this.loadImg(this.state.activeIndex),n=!0)}n&&e.preventDefault()},t.prototype.bindEvent=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="addEventListener";e&&(t="removeEventListener"),document[t]("keydown",this.handleKeydown,!1)},t.prototype.componentWillUnmount=function(){this.bindEvent(!0),this.refs.viewerCore.removeEventListener("transitionend",this.handleTransitionEnd,!1)},t.prototype.componentWillReceiveProps=function(e){var t=this;return!this.props.visible&&e.visible?void this.startVisible(e.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})},C)):this.props.activeIndex!==e.activeIndex?void this.handleChangeImg(e.activeIndex):void 0},t.prototype.render=function(){var e={src:"",alt:""},t=1e3;this.props.zIndex&&(t=this.props.zIndex);var n={opacity:this.state.visible?1:0};!this.state.visible&&this.state.transitionEnd&&(n.display="none"),!this.state.visible&&this.state.visibleStart&&(n.display="block"),this.state.visible&&this.state.transitionEnd&&(e=this.getActiveImage());var r=this.prefixCls+" "+this.prefixCls+"-transition";this.props.container&&(r+=" "+this.prefixCls+"-inline");var o=!1;return this.props.download&&(o=!0),p.createElement("div",{ref:"viewerCore",className:r,style:n},p.createElement("div",{className:this.prefixCls+"-mask",style:{zIndex:t}}),p.createElement("div",{className:this.prefixCls+"-close "+this.prefixCls+"-btn",onClick:this.handleClose.bind(this),style:{zIndex:t+10}},p.createElement(x.default,{type:b.ActionType.close})),p.createElement(h.default,{prefixCls:this.prefixCls,imgSrc:e.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,onZoom:this.handleZoom,zIndex:t+5,scaleX:this.state.scaleX,scaleY:this.state.scaleY,loading:this.state.loading,drag:this.props.drag,container:this.props.container,onCanvasMouseDown:this.handleCanvasMouseDown}),p.createElement("div",{className:this.prefixCls+"-footer",style:{zIndex:t+5}},p.createElement(v.default,{prefixCls:this.prefixCls,onAction:this.handleAction,alt:e.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:!0,downloadable:o}),p.createElement(m.default,{prefixCls:this.prefixCls,images:this.props.images,activeIndex:this.state.activeIndex,onChangeImg:this.handleChangeImg})))},t}(p.Component);t.default=w,w.defaultProps={visible:!1,onClose:s,images:[],activeIndex:0,zIndex:1e3,drag:!0,attribute:!0,zoomable:!0,rotatable:!0,scalable:!0,onMaskClick:s},e.exports=t.default},function(e,t,n){"use strict";function r(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 o(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;rc;)if(l=u[c++],l!=l)return!0}else for(;s>c;c++)if((e||c in u)&&u[c]===n)return e||c||0;return!e&&-1}}},function(e,t,n){var r=n(17),o=n(32),i=n(18);e.exports=function(e){var t=r(e),n=o.f;if(n)for(var a,l=n(e),u=i.f,s=0;l.length>s;)u.call(e,a=l[s++])&&t.push(a);return t}},function(e,t,n){var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){var r=n(45);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){"use strict";var r=n(31),o=n(19),i=n(33),a={};n(10)(a,n(12)("iterator"),function(){return this}),e.exports=function(e,t,n){e.prototype=r(a,{next:o(1,n)}),i(e,t+" Iterator")}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(20)("meta"),o=n(16),i=n(5),a=n(6).f,l=0,u=Object.isExtensible||function(){return!0},s=!n(15)(function(){return u(Object.preventExtensions({}))}),c=function(e){a(e,r,{value:{i:"O"+ ++l,w:{}}})},f=function(e,t){if(!o(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!i(e,r)){if(!u(e))return"F";if(!t)return"E";c(e)}return e[r].i},p=function(e,t){if(!i(e,r)){if(!u(e))return!0;if(!t)return!1;c(e)}return e[r].w},d=function(e){return s&&h.NEED&&u(e)&&!i(e,r)&&c(e),e},h=e.exports={KEY:r,NEED:!1,fastKey:f,getWeak:p,onFreeze:d}},function(e,t,n){"use strict";var r=n(17),o=n(32),i=n(18),a=n(55),l=n(49),u=Object.assign;e.exports=!u||n(15)(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=u({},e)[n]||Object.keys(u({},t)).join("")!=r})?function(e,t){for(var n=a(e),u=arguments.length,s=1,c=o.f,f=i.f;u>s;)for(var p,d=l(arguments[s++]),h=c?r(d).concat(c(d)):r(d),y=h.length,m=0;y>m;)f.call(d,p=h[m++])&&(n[p]=d[p]);return n}:u},function(e,t,n){var r=n(6),o=n(14),i=n(17);e.exports=n(4)?Object.defineProperties:function(e,t){o(e);for(var n,a=i(t),l=a.length,u=0;l>u;)r.f(e,n=a[u++],t[n]);return e}},function(e,t,n){var r=n(11),o=n(52).f,i={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],l=function(e){try{return o(e)}catch(e){return a.slice()}};e.exports.f=function(e){return a&&"[object Window]"==i.call(e)?l(e):o(r(e))}},function(e,t,n){var r=n(5),o=n(55),i=n(34)("IE_PROTO"),a=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=o(e),r(e,i)?e[i]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},function(e,t,n){var r=n(16),o=n(14),i=function(e,t){if(o(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{r=n(46)(Function.call,n(51).f(Object.prototype,"__proto__").set,2),r(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,n){return i(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:i}},function(e,t,n){var r=n(36),o=n(27);e.exports=function(e){return function(t,n){var i,a,l=String(o(t)),u=r(n),s=l.length;return u<0||u>=s?e?"":void 0:(i=l.charCodeAt(u),i<55296||i>56319||u+1===s||(a=l.charCodeAt(u+1))<56320||a>57343?e?l.charAt(u):i:e?l.slice(u,u+2):(i-55296<<10)+(a-56320)+65536)}}},function(e,t,n){var r=n(36),o=Math.max,i=Math.min;e.exports=function(e,t){return e=r(e),e<0?o(e+t,0):i(e,t)}},function(e,t,n){var r=n(36),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,t,n){"use strict";var r=n(90),o=n(96),i=n(29),a=n(11);e.exports=n(50)(Array,"Array",function(e,t){this._t=a(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,o(1)):"keys"==t?o(0,n):"values"==t?o(0,e[n]):o(0,[n,e[n]])},"values"),i.Arguments=i.Array,r("keys"),r("values"),r("entries")},function(e,t,n){var r=n(9);r(r.S+r.F,"Object",{assign:n(98)})},function(e,t,n){var r=n(9);r(r.S,"Object",{create:n(31)})},function(e,t,n){var r=n(9);r(r.S+r.F*!n(4),"Object",{defineProperty:n(6).f})},function(e,t,n){var r=n(9);r(r.S,"Object",{setPrototypeOf:n(102).set})},function(e,t){},function(e,t,n){"use strict";var r=n(103)(!0);n(50)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){"use strict";var r=n(2),o=n(5),i=n(4),a=n(9),l=n(54),u=n(97).KEY,s=n(15),c=n(35),f=n(33),p=n(20),d=n(12),h=n(39),y=n(38),m=n(92),g=n(94),v=n(14),b=n(11),x=n(37),C=n(19),w=n(31),S=n(100),M=n(51),E=n(6),L=n(17),k=M.f,T=E.f,j=S.f,O=r.Symbol,N=r.JSON,I=N&&N.stringify,_="prototype",P=d("_hidden"),A=d("toPrimitive"),D={}.propertyIsEnumerable,R=c("symbol-registry"),z=c("symbols"),U=c("op-symbols"),F=Object[_],H="function"==typeof O,V=r.QObject,Y=!V||!V[_]||!V[_].findChild,W=i&&s(function(){return 7!=w(T({},"a",{get:function(){return T(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=k(F,t);r&&delete F[t],T(e,t,n),r&&e!==F&&T(F,t,r)}:T,B=function(e){var t=z[e]=w(O[_]);return t._k=e,t},K=H&&"symbol"==typeof O.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof O},Q=function(e,t,n){return e===F&&Q(U,t,n),v(e),t=x(t,!0),v(n),o(z,t)?(n.enumerable?(o(e,P)&&e[P][t]&&(e[P][t]=!1),n=w(n,{enumerable:C(0,!1)})):(o(e,P)||T(e,P,C(1,{})),e[P][t]=!0),W(e,t,n)):T(e,t,n)},X=function(e,t){v(e);for(var n,r=m(t=b(t)),o=0,i=r.length;i>o;)Q(e,n=r[o++],t[n]);return e},G=function(e,t){return void 0===t?w(e):X(w(e),t)},$=function(e){var t=D.call(this,e=x(e,!0));return!(this===F&&o(z,e)&&!o(U,e))&&(!(t||!o(this,e)||!o(z,e)||o(this,P)&&this[P][e])||t)},q=function(e,t){if(e=b(e),t=x(t,!0),e!==F||!o(z,t)||o(U,t)){var n=k(e,t);return!n||!o(z,t)||o(e,P)&&e[P][t]||(n.enumerable=!0),n}},Z=function(e){for(var t,n=j(b(e)),r=[],i=0;n.length>i;)o(z,t=n[i++])||t==P||t==u||r.push(t);return r},J=function(e){for(var t,n=e===F,r=j(n?U:b(e)),i=[],a=0;r.length>a;)!o(z,t=r[a++])||n&&!o(F,t)||i.push(z[t]);return i};H||(O=function(){if(this instanceof O)throw TypeError("Symbol is not a constructor!");var e=p(arguments.length>0?arguments[0]:void 0),t=function(n){this===F&&t.call(U,n),o(this,P)&&o(this[P],e)&&(this[P][e]=!1),W(this,e,C(1,n))};return i&&Y&&W(F,e,{configurable:!0,set:t}),B(e)},l(O[_],"toString",function(){return this._k}),M.f=q,E.f=Q,n(52).f=S.f=Z,n(18).f=$,n(32).f=J,i&&!n(30)&&l(F,"propertyIsEnumerable",$,!0),h.f=function(e){return B(d(e))}),a(a.G+a.W+a.F*!H,{Symbol:O});for(var ee="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),te=0;ee.length>te;)d(ee[te++]);for(var ne=L(d.store),re=0;ne.length>re;)y(ne[re++]);a(a.S+a.F*!H,"Symbol",{for:function(e){return o(R,e+="")?R[e]:R[e]=O(e)},keyFor:function(e){if(!K(e))throw TypeError(e+" is not a symbol!");for(var t in R)if(R[t]===e)return t},useSetter:function(){Y=!0},useSimple:function(){Y=!1}}),a(a.S+a.F*!H,"Object",{create:G,defineProperty:Q,defineProperties:X,getOwnPropertyDescriptor:q,getOwnPropertyNames:Z,getOwnPropertySymbols:J}),N&&a(a.S+a.F*(!H||s(function(){var e=O();return"[null]"!=I([e])||"{}"!=I({a:e})||"{}"!=I(Object(e))})),"JSON",{stringify:function(e){if(void 0!==e&&!K(e)){for(var t,n,r=[e],o=1;arguments.length>o;)r.push(arguments[o++]);return t=r[1],"function"==typeof t&&(n=t),!n&&g(t)||(t=function(e,t){if(n&&(t=n.call(this,e,t)),!K(t))return t}),r[1]=t,I.apply(N,r)}}}),O[_][A]||n(10)(O[_],A,O[_].valueOf),f(O,"Symbol"),f(Math,"Math",!0),f(r.JSON,"JSON",!0)},function(e,t,n){n(38)("asyncIterator")},function(e,t,n){n(38)("observable")},function(e,t,n){n(106);for(var r=n(2),o=n(10),i=n(29),a=n(12)("toStringTag"),l="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),u=0;u0?(0,i.default)({marginLeft:u/-2,marginRight:u/-2},s):s,v=m.Children.map(c,function(e){return e?e.props&&u>0?(0,m.cloneElement)(e,{style:(0,i.default)({paddingLeft:u/2,paddingRight:u/2},e.props.style)}):e:null});return g.default.createElement("div",(0,i.default)({},d,{className:h,style:y}),v)}}]),t}(g.default.Component);t.default=S,S.defaultProps={gutter:0},S.propTypes={type:C.default.string,align:C.default.string,justify:C.default.string,className:C.default.string,children:C.default.node,gutter:C.default.number,prefixCls:C.default.string},e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(7),i=r(o),a=n(13),l=r(a),u=n(1),s=r(u),c=n(8),f=r(c),p=n(59),d=r(p),h=function(e){var t=e.type,n=e.className,r=void 0===n?"":n,o=e.spin,a=(0,f.default)((0,l.default)({anticon:!0,"anticon-spin":!!o||"loading"===t},"anticon-"+t,!0),r);return s.default.createElement("i",(0,i.default)({},(0,d.default)(e,["type","spin"]),{className:a}))};t.default=h,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(42);t.default=r.Row,e.exports=t.default},66,function(e,t,n){"use strict";function r(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 o(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;r0?1:-1:e.detail&&(t=e.detail>0?-1:1),0!==t){var n=e.clientX,r=e.clientY;if(this.props.container){var o=this.props.container.getBoundingClientRect();n-=o.left,r-=o.top}this.props.onZoom(n,r,t,.05)}},t.prototype.bindEvent=function(e){var t="addEventListener";e&&(t="removeEventListener");var n=document;this.props.container&&(n=this.props.container),n[t]("DOMMouseScroll",this.handleMouseScroll,!1),n[t]("mousewheel",this.handleMouseScroll,!1),document[t]("click",this.handleMouseUp,!1),document[t]("mousemove",this.handleMouseMove,!1),window[t]("resize",this.handleResize,!1)},t.prototype.componentWillReceiveProps=function(e){return!this.props.visible&&e.visible&&e.drag?this.bindEvent():this.props.visible&&!e.visible&&(this.handleMouseUp({}),e.drag)?this.bindEvent(!0):this.props.drag&&!e.drag?this.bindEvent(!0):!this.props.drag&&e.drag&&e.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:"translateX("+(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=this.props.drag?"drag":"";this.state.isMouseDown||(t+=" "+this.props.prefixCls+"-image-transition");var n={zIndex:this.props.zIndex},r=null;return""!==this.props.imgSrc&&(r=c.createElement("img",{className:t,src:this.props.imgSrc,style:e,onMouseDown:this.handleMouseDown})),this.props.loading&&(r=c.createElement("div",{style:{display:"flex",height:"100%",justifyContent:"center",alignItems:"center"}},c.createElement(p.default,null))),c.createElement("div",{className:this.props.prefixCls+"-canvas",onMouseDown:this.handleCanvasMouseDown,style:n},r)},t}(c.Component);t.default=d,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}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),r=0;r0&&r.state.activeIndex>=0&&(e=t[r.state.activeIndex]),e},r.prefixCls="react-viewer",r.state={visible:!1,visibleStart:!1,transitionEnd:!1,activeIndex:r.props.activeIndex,width:0,height:0,top:15,left:null,rotate:0,imageWidth:0,imageHeight:0,scaleX:1,scaleY:1,loading:!1},r.handleChangeImg=r.handleChangeImg.bind(r),r.handleChangeImgState=r.handleChangeImgState.bind(r),r.handleAction=r.handleAction.bind(r),r.handleResize=r.handleResize.bind(r),r.handleZoom=r.handleZoom.bind(r),r.handleRotate=r.handleRotate.bind(r),r.handleKeydown=r.handleKeydown.bind(r),r.handleScaleX=r.handleScaleX.bind(r),r.handleScaleY=r.handleScaleY.bind(r),r.getImageCenterXY=r.getImageCenterXY.bind(r),r.setContainerWidthHeight(),r.footerHeight=84,r}return u(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)},t.prototype.handleClose=function(e){this.props.onClose()},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}),setTimeout(function(){t.bindEvent(),t.loadImg(e,!0)},300)},10)},t.prototype.componentDidMount=function(){this.refs.viewerCore.addEventListener("transitionend",this.handleTransitionEnd,!1),this.startVisible(this.state.activeIndex)},t.prototype.getImgWidthHeight=function(e,t){var n=0,r=0,o=.8*this.containerWidth,i=.8*(this.containerHeight-this.footerHeight);return n=Math.min(o,e),r=n/e*t,r>i&&(r=i,n=r/t*e),[n,r]},t.prototype.loadImg=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="",o=this.props.images||[];o.length>0&&(r=o[e].src);var i=new Image;i.src=r,n?this.setState({activeIndex:e,width:0,height:0,left:0,top:0,rotate:0,scaleX:1,scaleY:1,loading:!0}):this.setState({activeIndex:e,loading:!0}),i.onload=function(){var r=i.width,o=i.height;if(n)setTimeout(function(){t.setState({activeIndex:e,imageWidth:r,imageHeight:o});var n=t.getImageCenterXY();t.handleZoom(n.x,n.y,1,1)},50);else{var a=t.getImgWidthHeight(r,o),l=c(a,2),u=l[0],s=l[1],f=(t.containerWidth-u)/2,p=(t.containerHeight-s-t.footerHeight)/2;t.setState({activeIndex:e,width:u,height:s,left:f,top:p,imageWidth:r,imageHeight:o,loading:!1,rotate:0,scaleX:1,scaleY:1})}},i.onerror=function(){t.setState({activeIndex:e,imageWidth:0,imageHeight:0,loading:!1})}},t.prototype.handleChangeImg=function(e){this.loadImg(e)},t.prototype.handleChangeImgState=function(e,t,n,r){this.setState({width:e,height:t,top:n,left:r})},t.prototype.handleAction=function(e){switch(e){case b.ActionType.prev:this.state.activeIndex-1>=0&&this.handleChangeImg(this.state.activeIndex-1);break;case b.ActionType.next:this.state.activeIndex+10?1:-1,x=this.state.scaleY>0?1:-1;if(d=this.state.scaleX+r*n*b,h=this.state.scaleY+r*n*x,Math.abs(d)<.1||Math.abs(h)<.1)return;u=this.state.top+-n*a/this.state.scaleX*r*b,s=this.state.left+-n*i/this.state.scaleY*r*x,f=this.state.width,p=this.state.height}this.setState({width:f,scaleX:d,scaleY:h,height:p,top:u,left:s,loading:!1})},t.prototype.getImageCenterXY=function(){return{x:this.state.left+this.state.width/2,y:this.state.top+this.state.height/2}},t.prototype.handleRotate=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.setState({rotate:this.state.rotate+90*(e?1:-1)})},t.prototype.handleResize=function(){if(this.setContainerWidthHeight(),this.props.visible){var e=this.getImgWidthHeight(this.state.imageWidth,this.state.imageHeight),t=c(e,2),n=t[0],r=t[1],o=(this.containerWidth-n)/2,i=(this.containerHeight-r-this.footerHeight)/2;this.setState({width:n,height:r,left:o,top:i,rotate:0,scaleX:1,scaleY:1})}},t.prototype.handleKeydown=function(e){var t=e.keyCode||e.which||e.charCode,n=!1;switch(t){case 27:this.props.onClose(),n=!0;break;case 37:e.ctrlKey?this.handleAction(b.ActionType.rotateLeft):this.handleAction(b.ActionType.prev),n=!0;break;case 39:e.ctrlKey?this.handleAction(b.ActionType.rotateRight):this.handleAction(b.ActionType.next),n=!0;break;case 38:this.handleAction(b.ActionType.zoomIn),n=!0;break;case 40:this.handleAction(b.ActionType.zoomOut),n=!0;break;case 49:e.ctrlKey&&(this.loadImg(this.state.activeIndex),n=!0)}n&&e.preventDefault()},t.prototype.bindEvent=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="addEventListener";e&&(t="removeEventListener"),document[t]("keydown",this.handleKeydown,!1)},t.prototype.componentWillUnmount=function(){this.bindEvent(!0),this.refs.viewerCore.removeEventListener("transitionend",this.handleTransitionEnd,!1)},t.prototype.componentWillReceiveProps=function(e){var t=this;return!this.props.visible&&e.visible?void this.startVisible(e.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})},C)):this.props.activeIndex!==e.activeIndex?void this.handleChangeImg(e.activeIndex):void 0},t.prototype.render=function(){var e={src:"",alt:""},t=1e3;this.props.zIndex&&(t=this.props.zIndex);var n={opacity:this.state.visible?1:0};!this.state.visible&&this.state.transitionEnd&&(n.display="none"),!this.state.visible&&this.state.visibleStart&&(n.display="block"),this.state.visible&&this.state.transitionEnd&&(e=this.getActiveImage());var r=this.prefixCls+" "+this.prefixCls+"-transition";return this.props.container&&(r+=" "+this.prefixCls+"-inline"),p.createElement("div",{ref:"viewerCore",className:r,style:n},p.createElement("div",{className:this.prefixCls+"-mask",style:{zIndex:t}}),p.createElement("div",{className:this.prefixCls+"-close "+this.prefixCls+"-btn",onClick:this.handleClose.bind(this),style:{zIndex:t+10}},p.createElement(x.default,{type:b.ActionType.close})),p.createElement(h.default,{prefixCls:this.prefixCls,imgSrc:e.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,onZoom:this.handleZoom,zIndex:t+5,scaleX:this.state.scaleX,scaleY:this.state.scaleY,loading:this.state.loading,drag:this.props.drag,container:this.props.container,onCanvasMouseDown:this.handleCanvasMouseDown}),p.createElement("div",{className:this.prefixCls+"-footer",style:{zIndex:t+5}},p.createElement(v.default,{prefixCls:this.prefixCls,onAction:this.handleAction,alt:e.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:!0,downloadable:this.props.downloadable}),p.createElement(m.default,{prefixCls:this.prefixCls,images:this.props.images,activeIndex:this.state.activeIndex,onChangeImg:this.handleChangeImg})))},t}(p.Component);t.default=w,w.defaultProps={visible:!1,onClose:s,images:[],activeIndex:0,zIndex:1e3,drag:!0,attribute:!0,zoomable:!0,rotatable:!0,scalable:!0,onMaskClick:s},e.exports=t.default},function(e,t,n){"use strict";function r(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 o(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;rc;)if(l=u[c++],l!=l)return!0}else for(;s>c;c++)if((e||c in u)&&u[c]===n)return e||c||0;return!e&&-1}}},function(e,t,n){var r=n(17),o=n(32),i=n(18);e.exports=function(e){var t=r(e),n=o.f;if(n)for(var a,l=n(e),u=i.f,s=0;l.length>s;)u.call(e,a=l[s++])&&t.push(a);return t}},function(e,t,n){var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){var r=n(45);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){"use strict";var r=n(31),o=n(19),i=n(33),a={};n(10)(a,n(12)("iterator"),function(){return this}),e.exports=function(e,t,n){e.prototype=r(a,{next:o(1,n)}),i(e,t+" Iterator")}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(20)("meta"),o=n(16),i=n(5),a=n(6).f,l=0,u=Object.isExtensible||function(){return!0},s=!n(15)(function(){return u(Object.preventExtensions({}))}),c=function(e){a(e,r,{value:{i:"O"+ ++l,w:{}}})},f=function(e,t){if(!o(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!i(e,r)){if(!u(e))return"F";if(!t)return"E";c(e)}return e[r].i},p=function(e,t){if(!i(e,r)){if(!u(e))return!0;if(!t)return!1;c(e)}return e[r].w},d=function(e){return s&&h.NEED&&u(e)&&!i(e,r)&&c(e),e},h=e.exports={KEY:r,NEED:!1,fastKey:f,getWeak:p,onFreeze:d}},function(e,t,n){"use strict";var r=n(17),o=n(32),i=n(18),a=n(55),l=n(49),u=Object.assign;e.exports=!u||n(15)(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=u({},e)[n]||Object.keys(u({},t)).join("")!=r})?function(e,t){for(var n=a(e),u=arguments.length,s=1,c=o.f,f=i.f;u>s;)for(var p,d=l(arguments[s++]),h=c?r(d).concat(c(d)):r(d),y=h.length,m=0;y>m;)f.call(d,p=h[m++])&&(n[p]=d[p]);return n}:u},function(e,t,n){var r=n(6),o=n(14),i=n(17);e.exports=n(4)?Object.defineProperties:function(e,t){o(e);for(var n,a=i(t),l=a.length,u=0;l>u;)r.f(e,n=a[u++],t[n]);return e}},function(e,t,n){var r=n(11),o=n(52).f,i={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],l=function(e){try{return o(e)}catch(e){return a.slice()}};e.exports.f=function(e){return a&&"[object Window]"==i.call(e)?l(e):o(r(e))}},function(e,t,n){var r=n(5),o=n(55),i=n(34)("IE_PROTO"),a=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=o(e),r(e,i)?e[i]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},function(e,t,n){var r=n(16),o=n(14),i=function(e,t){if(o(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{r=n(46)(Function.call,n(51).f(Object.prototype,"__proto__").set,2),r(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,n){return i(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:i}},function(e,t,n){var r=n(36),o=n(27);e.exports=function(e){return function(t,n){var i,a,l=String(o(t)),u=r(n),s=l.length;return u<0||u>=s?e?"":void 0:(i=l.charCodeAt(u),i<55296||i>56319||u+1===s||(a=l.charCodeAt(u+1))<56320||a>57343?e?l.charAt(u):i:e?l.slice(u,u+2):(i-55296<<10)+(a-56320)+65536)}}},function(e,t,n){var r=n(36),o=Math.max,i=Math.min;e.exports=function(e,t){return e=r(e),e<0?o(e+t,0):i(e,t)}},function(e,t,n){var r=n(36),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,t,n){"use strict";var r=n(90),o=n(96),i=n(29),a=n(11);e.exports=n(50)(Array,"Array",function(e,t){this._t=a(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,o(1)):"keys"==t?o(0,n):"values"==t?o(0,e[n]):o(0,[n,e[n]])},"values"),i.Arguments=i.Array,r("keys"),r("values"),r("entries")},function(e,t,n){var r=n(9);r(r.S+r.F,"Object",{assign:n(98)})},function(e,t,n){var r=n(9);r(r.S,"Object",{create:n(31)})},function(e,t,n){var r=n(9);r(r.S+r.F*!n(4),"Object",{defineProperty:n(6).f})},function(e,t,n){var r=n(9);r(r.S,"Object",{setPrototypeOf:n(102).set})},function(e,t){},function(e,t,n){"use strict";var r=n(103)(!0);n(50)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){"use strict";var r=n(2),o=n(5),i=n(4),a=n(9),l=n(54),u=n(97).KEY,s=n(15),c=n(35),f=n(33),p=n(20),d=n(12),h=n(39),y=n(38),m=n(92),g=n(94),v=n(14),b=n(11),x=n(37),C=n(19),w=n(31),S=n(100),M=n(51),E=n(6),L=n(17),k=M.f,T=E.f,j=S.f,O=r.Symbol,N=r.JSON,I=N&&N.stringify,_="prototype",P=d("_hidden"),A=d("toPrimitive"),D={}.propertyIsEnumerable,R=c("symbol-registry"),z=c("symbols"),U=c("op-symbols"),F=Object[_],H="function"==typeof O,V=r.QObject,Y=!V||!V[_]||!V[_].findChild,W=i&&s(function(){return 7!=w(T({},"a",{get:function(){return T(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=k(F,t);r&&delete F[t],T(e,t,n),r&&e!==F&&T(F,t,r)}:T,B=function(e){var t=z[e]=w(O[_]);return t._k=e,t},K=H&&"symbol"==typeof O.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof O},Q=function(e,t,n){return e===F&&Q(U,t,n),v(e),t=x(t,!0),v(n),o(z,t)?(n.enumerable?(o(e,P)&&e[P][t]&&(e[P][t]=!1),n=w(n,{enumerable:C(0,!1)})):(o(e,P)||T(e,P,C(1,{})),e[P][t]=!0),W(e,t,n)):T(e,t,n)},X=function(e,t){v(e);for(var n,r=m(t=b(t)),o=0,i=r.length;i>o;)Q(e,n=r[o++],t[n]);return e},G=function(e,t){return void 0===t?w(e):X(w(e),t)},$=function(e){var t=D.call(this,e=x(e,!0));return!(this===F&&o(z,e)&&!o(U,e))&&(!(t||!o(this,e)||!o(z,e)||o(this,P)&&this[P][e])||t)},q=function(e,t){if(e=b(e),t=x(t,!0),e!==F||!o(z,t)||o(U,t)){var n=k(e,t);return!n||!o(z,t)||o(e,P)&&e[P][t]||(n.enumerable=!0),n}},Z=function(e){for(var t,n=j(b(e)),r=[],i=0;n.length>i;)o(z,t=n[i++])||t==P||t==u||r.push(t);return r},J=function(e){for(var t,n=e===F,r=j(n?U:b(e)),i=[],a=0;r.length>a;)!o(z,t=r[a++])||n&&!o(F,t)||i.push(z[t]);return i};H||(O=function(){if(this instanceof O)throw TypeError("Symbol is not a constructor!");var e=p(arguments.length>0?arguments[0]:void 0),t=function(n){this===F&&t.call(U,n),o(this,P)&&o(this[P],e)&&(this[P][e]=!1),W(this,e,C(1,n))};return i&&Y&&W(F,e,{configurable:!0,set:t}),B(e)},l(O[_],"toString",function(){return this._k}),M.f=q,E.f=Q,n(52).f=S.f=Z,n(18).f=$,n(32).f=J,i&&!n(30)&&l(F,"propertyIsEnumerable",$,!0),h.f=function(e){return B(d(e))}),a(a.G+a.W+a.F*!H,{Symbol:O});for(var ee="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),te=0;ee.length>te;)d(ee[te++]);for(var ne=L(d.store),re=0;ne.length>re;)y(ne[re++]);a(a.S+a.F*!H,"Symbol",{for:function(e){return o(R,e+="")?R[e]:R[e]=O(e)},keyFor:function(e){if(!K(e))throw TypeError(e+" is not a symbol!");for(var t in R)if(R[t]===e)return t},useSetter:function(){Y=!0},useSimple:function(){Y=!1}}),a(a.S+a.F*!H,"Object",{create:G,defineProperty:Q,defineProperties:X,getOwnPropertyDescriptor:q,getOwnPropertyNames:Z,getOwnPropertySymbols:J}),N&&a(a.S+a.F*(!H||s(function(){var e=O();return"[null]"!=I([e])||"{}"!=I({a:e})||"{}"!=I(Object(e))})),"JSON",{stringify:function(e){if(void 0!==e&&!K(e)){for(var t,n,r=[e],o=1;arguments.length>o;)r.push(arguments[o++]);return t=r[1],"function"==typeof t&&(n=t),!n&&g(t)||(t=function(e,t){if(n&&(t=n.call(this,e,t)),!K(t))return t}),r[1]=t,I.apply(N,r)}}}),O[_][A]||n(10)(O[_],A,O[_].valueOf),f(O,"Symbol"),f(Math,"Math",!0),f(r.JSON,"JSON",!0)},function(e,t,n){n(38)("asyncIterator")},function(e,t,n){n(38)("observable")},function(e,t,n){n(106);for(var r=n(2),o=n(10),i=n(29),a=n(12)("toStringTag"),l="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),u=0;u { const activeImage = this.getActiveImage(); - if (this.props.download && this.props.download.onDownload) { - this.props.download.onDownload(activeImage.src); + if (activeImage.downloadUrl) { + window.open(activeImage.downloadUrl); } } @@ -473,6 +473,7 @@ export default class ViewerCore extends React.Component ) => void; - /** 下载配置 */ - download?: { - onDownload: (url) => void; - }; + /** 是否显示下载按钮 */ + downloadable?: boolean; } export default ViewerProps;