From a87103a0e66bc789a9d6765928427dd4c9de0cbb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 18 May 2022 18:21:59 +0200 Subject: [PATCH] Image viewer broke during orientation change See https://www.woltlab.com/community/thread/295628-mobil-bildanzeige-skaliert-beim-drehen/ --- wcfsetup/install/files/js/WCF.ImageViewer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 54ca2cbf12..0fcd4ab604 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -511,7 +511,12 @@ $.widget('ui.wcfImageViewer', { */ _bindListener: function() { $(document).on('keydown.' + this._eventNamespace, $.proxy(this._keyDown, this)); - $(window).on('resize.' + this._eventNamespace, $.proxy(this._renderImage, this)); + $(window).on('resize.' + this._eventNamespace, () => { + // The resize event can trigger before the mobile UI has + // adapted to the new screen size (`screen-sm-down` no + // longer matches or previously did not match). + window.setTimeout(() => this._renderImage(), 0); + }); }, /** -- 2.20.1