diff --git a/lib/FullScreen.js b/lib/FullScreen.js index 296f02f..0f1b2f7 100644 --- a/lib/FullScreen.js +++ b/lib/FullScreen.js @@ -69,6 +69,11 @@ function (_ImageViewer) { display: 'none' }); // enable scroll + // escape listener + document.removeEventListener('keyup', _this._events.escapeListener); + // Android back button listener + document.removeEventListener('backbutton', _this._events.androidBackButtonListener); + (0, _util.removeCss)(document.querySelector('html'), 'overflow'); // remove window event _this._events.onWindowResize(); @@ -101,6 +106,21 @@ function (_ImageViewer) { this.load(imageSrc, hiResImageSrc); } // handle window resize + // escape listener + this._events.escapeListener = (e) => { + if (e.keyCode === 27 || e.key === 'Escape') { + this.hide(); + e.preventDefault(); + } + } + document.addEventListener('keyup', this._events.escapeListener); + + // Android back button listener + this._events.androidBackButtonListener = (e) => { + this.hide(); + e.preventDefault(); + } + document.addEventListener('backbutton', this._events.androidBackButtonListener); this._events.onWindowResize = (0, _util.assignEvent)(window, 'resize', this.refresh); // disable scroll on html @@ -124,4 +144,4 @@ function (_ImageViewer) { }(_ImageViewer2.default); var _default = FullScreenViewer; -exports.default = _default; \ No newline at end of file +exports.default = _default;