David Catuhe il y a 5 ans
Parent
commit
6934090a3e
1 fichiers modifiés avec 13 ajouts et 1 suppressions
  1. 13 1
      gui/src/2D/controls/scrollViewers/scrollViewer.ts

+ 13 - 1
gui/src/2D/controls/scrollViewers/scrollViewer.ts

@@ -44,6 +44,9 @@ export class ScrollViewer extends Rectangle {
     private _barImageHeight: number = 1;
     private _horizontalBarImageHeight: number = 1;
     private _verticalBarImageHeight: number = 1;
+    private _oldWindowContentsWidth: number = 0;
+    private _oldWindowContentsHeight: number = 0;
+
     /**
      * Gets the horizontal scrollbar
      */
@@ -261,6 +264,8 @@ export class ScrollViewer extends Rectangle {
         super._postMeasure();
 
         this._updateScroller();
+
+        this._setWindowPosition(false);
     }
 
     /**
@@ -556,11 +561,18 @@ export class ScrollViewer extends Rectangle {
         vb.backgroundImage = value;
     }
 
-    private _setWindowPosition(): void {
+    private _setWindowPosition(force = true): void {
         let ratio = this.host.idealRatio;
         let windowContentsWidth = this._window._currentMeasure.width;
         let windowContentsHeight = this._window._currentMeasure.height;
 
+        if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
+            return;
+        }
+
+        this._oldWindowContentsWidth = windowContentsWidth;
+        this._oldWindowContentsHeight = windowContentsHeight;
+
         const _endLeft = this._clientWidth - windowContentsWidth;
         const _endTop = this._clientHeight - windowContentsHeight;