Fix bug 52626, 52622: Media Viewer crash

This commit is contained in:
Viktor Fomin 2021-09-21 13:48:13 +03:00
parent e87329f2d3
commit 6691e523a8

View File

@ -109,7 +109,8 @@ class MediaViewer extends React.Component {
_this.hammer.on("swiperight", _this.prevMedia);
}
} catch (ex) {
console.error("MediaViewer updateHammer", ex);
//console.error("MediaViewer updateHammer", ex);
this.hammer = null;
}
}, 500);
}
@ -190,33 +191,15 @@ class MediaViewer extends React.Component {
if (ext === ".tiff" || ext === ".tif") {
this.getTiffDataURL(src);
}
var _this = this;
setTimeout(function () {
if (document.getElementsByClassName("react-viewer-canvas").length > 0) {
_this.hammer = Hammer(
document.getElementsByClassName("react-viewer-canvas")[0]
);
var pinch = new Hammer.Pinch();
_this.hammer.add([pinch]);
_this.hammer.on("pinchout", _this.handleZoomOut);
_this.hammer.on("pinchin", _this.handleZoomIn);
_this.hammer.on("pinchend", _this.handleZoomEnd);
_this.hammer.on("doubletap", _this.doubleTap);
} else {
_this.hammer = Hammer(
document.getElementsByClassName("videoViewerOverlay")[0]
);
}
if (_this.hammer) {
_this.hammer.on("swipeleft", _this.nextMedia);
_this.hammer.on("swiperight", _this.prevMedia);
}
}, 500);
this.updateHammer();
document.addEventListener("keydown", this.onKeydown, false);
document.addEventListener("keyup", this.onKeyup, false);
}
componentWillUnmount() {
console.log("unmount mediaviewer");
if (this.hammer) {
this.hammer.off("swipeleft", this.nextMedia);
this.hammer.off("swiperight", this.prevMedia);
@ -227,6 +210,7 @@ class MediaViewer extends React.Component {
}
document.removeEventListener("keydown", this.onKeydown, false);
document.removeEventListener("keyup", this.onKeyup, false);
this.onClose();
}
mapSupplied = {