react-admin-component
Version:
react library
43 lines • 1.89 kB
JavaScript
import * as tslib_1 from "tslib";
import React, { Component } from 'react';
import { ModalCustom } from '..';
var imgPreviewInstance = new ModalCustom();
var ImgPreviewSource = (function (_super) {
tslib_1.__extends(ImgPreviewSource, _super);
function ImgPreviewSource(props) {
var _this = _super.call(this, props) || this;
_this.loadImg = function (event) {
var _a = event.currentTarget, naturalHeight = _a.naturalHeight, naturalWidth = _a.naturalWidth;
_this.setState({
naturalHeight: naturalHeight,
naturalWidth: naturalWidth,
});
};
_this.close = function () {
imgPreviewInstance.destroy();
};
_this.state = {
naturalHeight: 'auto',
naturalWidth: 'auto',
};
_this.displayName = 'ImgPreviewSource';
return _this;
}
ImgPreviewSource.prototype.componentWillUnmount = function () {
};
ImgPreviewSource.prototype.render = function () {
var _a = this.state, naturalWidth = _a.naturalWidth, naturalHeight = _a.naturalHeight;
var imgSrc = this.props.imgSrc;
return (React.createElement("div", { className: "imgps_root" },
React.createElement("img", { src: imgSrc, width: naturalWidth, height: naturalHeight, alt: "\u539F\u56FE", onLoad: this.loadImg, className: "imgps_img_ratio" }),
React.createElement("div", { className: "imgps_close", onClick: this.close },
React.createElement("i", { className: "imgps_icon", style: { color: '#ffffff' } }))));
};
return ImgPreviewSource;
}(Component));
export default {
showImgSource: function (imgSrc) {
imgPreviewInstance.show(React.createElement(ImgPreviewSource, { imgSrc: imgSrc }));
},
};
//# sourceMappingURL=index.js.map