viewerjs-react
Version:
Typescript supported react wrapper for viewerjs.
63 lines (47 loc) • 1.39 kB
JavaScript
import { createElement, PureComponent } from 'react';
import ViewerJS from 'viewerjs';
import 'viewerjs/dist/viewer.css';
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var RViewerJS = /*#__PURE__*/function (_React$PureComponent) {
_inheritsLoose(RViewerJS, _React$PureComponent);
function RViewerJS() {
var _this;
_this = _React$PureComponent.apply(this, arguments) || this;
_this.viewer = null;
_this.onRef = function (el) {
if (!el) {
return;
}
if (_this.viewer) {
_this.viewer.destroy();
}
_this.viewer = new ViewerJS(el, _this.props.options);
};
return _this;
}
var _proto = RViewerJS.prototype;
_proto.componentDidUpdate = function componentDidUpdate() {
if (this.viewer) {
this.viewer.update();
}
};
_proto.componentWillUnmount = function componentWillUnmount() {
if (this.viewer) {
this.viewer.destroy();
}
this.viewer = null;
};
_proto.render = function render() {
return createElement("div", {
ref: this.onRef,
className: this.props.className
}, this.props.children);
};
return RViewerJS;
}(PureComponent);
export default RViewerJS;
//# sourceMappingURL=index.modern.js.map