{"version":3,"sources":["../../../src/components/ImagePreviewer/ImagePreviewer.jsx"],"names":["ImagePreviewer","props","setIndex","bind","onPrev","onNext","onOrigin","rotateLeft","rotateRight","onImgLoad","onImageError","state","cIndex","index","direction","loading","nextProps","prev","list","length","next","window","open","setState","onFold","large","transform","opacity","transition","map","item","backgroundImage","small","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAGA;;AACA;;;;;;;;;;IAEqBA,c;;;AACjB,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA,oIACTA,KADS;;AAEf,cAAKC,QAAL,GAAgB,MAAKA,QAAL,CAAcC,IAAd,OAAhB;AACA,cAAKC,MAAL,GAAc,MAAKA,MAAL,CAAYD,IAAZ,OAAd;AACA,cAAKE,MAAL,GAAc,MAAKA,MAAL,CAAYF,IAAZ,OAAd;AACA,cAAKG,QAAL,GAAgB,MAAKA,QAAL,CAAcH,IAAd,OAAhB;AACA,cAAKI,UAAL,GAAkB,MAAKA,UAAL,CAAgBJ,IAAhB,OAAlB;AACA,cAAKK,WAAL,GAAmB,MAAKA,WAAL,CAAiBL,IAAjB,OAAnB;AACA,cAAKM,SAAL,GAAiB,MAAKA,SAAL,CAAeN,IAAf,OAAjB;AACA,cAAKO,YAAL,GAAoB,MAAKA,YAAL,CAAkBP,IAAlB,OAApB;AACA,cAAKQ,KAAL,GAAa;AACTC,oBAAQX,MAAMY,KADL;AAETC,uBAAW,CAFF,EAEK;AACdC,qBAAS;AAHA,SAAb;AAVe;AAelB;;;;kDAEyBC,S,EAAW;AACjC,gBAAIA,UAAUH,KAAV,KAAoB,KAAKZ,KAAL,CAAWY,KAAnC,EAA0C;AACtC,qBAAKX,QAAL,CAAcc,UAAUH,KAAxB;AACH;AACJ;;;iCAEQ;AACL,gBAAMI,OAAO,KAAKN,KAAL,CAAWC,MAAX,KAAsB,CAAtB,GAA0B,KAAKX,KAAL,CAAWiB,IAAX,CAAgBC,MAAhB,GAAyB,CAAnD,GAAuD,K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AACC,IAAD,EAAOjB,KAAP;AAAA,+BACN;AAAA;AAAA;AACI,2CAAW,0BAAW;AAClB,+CAAW,IADO;AAElB,8CAAUA,UAAUD;AAFF,iCAAX,CADf;AAKI,qCAAKkB;AALT;AAOI;AACI,2CAAW,0BAAW;AAClB,iDAAa;AADK,iCAAX,CADf;AAII,uCAAO;AACHC,8DAAwB,6BAAgBD,IAAhB,EAAsB;AAC1CE,+CAAO;AADmC,qCAAtB,CAAxB;AADG,iCAJX;AASI,yCAAS,mBAAM;AACX,2CAAK9B,QAAL,CAAcW,KAAd;AACH;AAXL;AAPJ,yBADM;AAAA,qBAAT;AADL;AA5DR,aADJ;AAyFH;;;;EA9KuCoB,gBAAMC,S;;kBAA7BlC,c","file":"ImagePreviewer.js","sourcesContent":["import React from 'react';\r\nimport classnames from 'classnames';\r\nimport { Icon, Spin } from 'antd';\r\n\r\nimport './ImagePreviewer.css';\r\nimport { addImageProcess } from '../../helper';\r\n\r\nexport default class ImagePreviewer extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.setIndex = this.setIndex.bind(this);\r\n this.onPrev = this.onPrev.bind(this);\r\n this.onNext = this.onNext.bind(this);\r\n this.onOrigin = this.onOrigin.bind(this);\r\n this.rotateLeft = this.rotateLeft.bind(this);\r\n this.rotateRight = this.rotateRight.bind(this);\r\n this.onImgLoad = this.onImgLoad.bind(this);\r\n this.onImageError = this.onImageError.bind(this);\r\n this.state = {\r\n cIndex: props.index,\r\n direction: 0, // 0- 0deg 1- 90deg 2- 180deg 3- 270deg\r\n loading: false,\r\n };\r\n }\r\n\r\n componentWillReceiveProps(nextProps) {\r\n if (nextProps.index !== this.props.index) {\r\n this.setIndex(nextProps.index);\r\n }\r\n }\r\n\r\n onPrev() {\r\n const prev = this.state.cIndex === 0 ? this.props.list.length - 1 : this.state.cIndex - 1;\r\n this.setIndex(prev);\r\n }\r\n\r\n onNext() {\r\n const next = this.state.cIndex === this.props.list.length - 1 ? 0 : this.state.cIndex + 1;\r\n this.setIndex(next);\r\n }\r\n\r\n onOrigin() {\r\n window.open(this.props.list[this.state.cIndex]);\r\n }\r\n\r\n onImgLoad() {\r\n this.setState({\r\n loading: false,\r\n });\r\n }\r\n\r\n onImageError() {\r\n this.setState({\r\n loading: false,\r\n });\r\n }\r\n\r\n setIndex(index) {\r\n this.setState({\r\n cIndex: index,\r\n direction: 0,\r\n loading: true,\r\n });\r\n }\r\n\r\n rotateLeft() {\r\n let direction = this.state.direction - 1;\r\n if (direction === -1) {\r\n direction = 3;\r\n }\r\n this.setState({\r\n direction,\r\n });\r\n }\r\n\r\n rotateRight() {\r\n let direction = this.state.direction + 1;\r\n if (direction === 4) {\r\n direction = 0;\r\n }\r\n this.setState({\r\n direction,\r\n });\r\n }\r\n\r\n // calcHeight(node) {\r\n // const { naturalHeight, naturalWidth } = node;\r\n // }\r\n\r\n render() {\r\n const { list, onFold } = this.props;\r\n const { cIndex } = this.state;\r\n return (\r\n
\r\n
\r\n \r\n 收起\r\n \r\n \r\n 查看原图\r\n \r\n {/* \r\n 向右旋转\r\n \r\n \r\n 向左旋转\r\n */}\r\n
\r\n
\r\n \r\n {\r\n // if (node) {\r\n // this.calcHeight(node);\r\n // }\r\n // }}\r\n className=\"picture\"\r\n src={addImageProcess(list[cIndex], { large: true })}\r\n alt={list[cIndex]}\r\n style={{\r\n transform: `rotate(${this.state.direction * 90}deg)`,\r\n opacity: this.state.loading ? 0 : 1,\r\n transition: '0.3s opacity',\r\n }}\r\n onLoad={this.onImgLoad}\r\n onError={this.onImageError}\r\n />\r\n \r\n
\r\n {list.length > 1 && (\r\n \r\n )}\r\n\r\n
\r\n {list.length > 1 && (\r\n \r\n )}\r\n
\r\n {/*
\r\n \r\n
\r\n
\r\n \r\n
*/}\r\n {/*
*/}\r\n
\r\n {list.length > 1 && (\r\n
\r\n {list.map((item, index) => (\r\n \r\n {\r\n this.setIndex(index);\r\n }}\r\n />\r\n
\r\n ))}\r\n
\r\n )}\r\n
\r\n );\r\n }\r\n}\r\n"]}