From 3258e4e1e6db1c83fbf2e11da04c9c0238e7b242 Mon Sep 17 00:00:00 2001 From: hasannabtiti98 <101595980+hasannabtiti98@users.noreply.github.com> Date: Mon, 14 Mar 2022 22:35:52 +0300 Subject: [PATCH 1/2] Update zoom.js --- js/zoom.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/js/zoom.js b/js/zoom.js index 1348757..1d01af3 100755 --- a/js/zoom.js +++ b/js/zoom.js @@ -10,8 +10,7 @@ this._touchMoveListener = null this._$document = $(document) - this._$window = $(window) - this._$body = $(document.body) + //this._$window = $(window) this._boundClick = $.proxy(this._clickHandler, this) } @@ -31,18 +30,7 @@ return window.open((e.target.getAttribute('data-original') || e.target.src), '_blank') } - if (target.width >= ($(window).width() - Zoom.OFFSET)) return - this._activeZoomClose(true) - - this._activeZoom = new Zoom(target) - this._activeZoom.zoomImage() - - // todo(fat): probably worth throttling this - this._$window.on('scroll.zoom', $.proxy(this._scrollHandler, this)) - - this._$document.on('keyup.zoom', $.proxy(this._keyHandler, this)) - this._$document.on('touchstart.zoom', $.proxy(this._touchStart, this)) // we use a capturing phase here to prevent unintended js events // sadly no useCapture in jquery api (http://bugs.jquery.com/ticket/14953) @@ -71,9 +59,9 @@ this._$window.off('.zoom') this._$document.off('.zoom') - +document.addEventListener('click', this._boundClick, true) document.removeEventListener('click', this._boundClick, true) - +document.addEventListener('click', this._boundClick, true) this._activeZoom = null } @@ -90,14 +78,14 @@ ZoomService.prototype._clickHandler = function (e) { if (e.preventDefault) e.preventDefault() else event.returnValue = false - +document.addEventListener('click', this._boundClick, true) if ('bubbles' in e) { if (e.bubbles) e.stopPropagation() } else { // Internet Explorer before version 9 e.cancelBubble = true } - +document.addEventListener('click', this._boundClick, true) this._activeZoomClose() } From 65feb1b0394e4a7ae7e2c9f2b273f84e88410654 Mon Sep 17 00:00:00 2001 From: hasannabtiti98 <101595980+hasannabtiti98@users.noreply.github.com> Date: Mon, 14 Mar 2022 22:43:19 +0300 Subject: [PATCH 2/2] Update zoom.js --- js/zoom.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/js/zoom.js b/js/zoom.js index 1d01af3..d9ffba0 100755 --- a/js/zoom.js +++ b/js/zoom.js @@ -9,26 +9,11 @@ this._initialTouchPosition = this._touchMoveListener = null - this._$document = $(document) - //this._$window = $(window) - this._boundClick = $.proxy(this._clickHandler, this) } - ZoomService.prototype.listen = function () { - this._$body.on('click', '[data-action="zoom"]', $.proxy(this._zoom, this)) } - ZoomService.prototype._zoom = function (e) { - var target = e.target - - if (!target || target.tagName != 'IMG') return - - if (this._$body.hasClass('zoom-overlay-open')) return - - if (e.metaKey || e.ctrlKey) { - return window.open((e.target.getAttribute('data-original') || e.target.src), '_blank') - } @@ -50,6 +35,13 @@ ZoomService.prototype._activeZoomClose = function (forceDispose) { if (!this._activeZoom) return + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) + document.addEventListener('click', this._boundClick, true) if (forceDispose) { this._activeZoom.dispose()