Image viewer broke during orientation change
authorAlexander Ebert <ebert@woltlab.com>
Wed, 18 May 2022 16:21:59 +0000 (18:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 18 May 2022 16:21:59 +0000 (18:21 +0200)
See https://www.woltlab.com/community/thread/295628-mobil-bildanzeige-skaliert-beim-drehen/

wcfsetup/install/files/js/WCF.ImageViewer.js

index 54ca2cbf12699b7175b8e9c4de1a12d91c038320..0fcd4ab604dc621d8a7e310151d436f305d4d7f4 100644 (file)
@@ -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);
+               });
        },
        
        /**