From e7969b0ea23ced8b6c1d77f56726cc558c2d9a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 24 Dec 2023 11:11:14 +0100 Subject: [PATCH] animation: Save file and dimensions in properties The properties passed to the constructor are currently used directly in anonymous functions. Store them in properties instead, so they become accessible outside the constructor, including for changing them. Part-of: (cherry picked from commit 74445249db7c0df9e582a60f2f15401b7f2c7267) --- js/ui/animation.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/ui/animation.js b/js/ui/animation.js index c300c841f..85b4d5d73 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -21,14 +21,20 @@ class Animation extends St.Bin { style: `width: ${width}px; height: ${height}px;`, }); + this._file = file; + this._width = width; + this._height = height; + this.connect('destroy', this._onDestroy.bind(this)); this.connect('resource-scale-changed', - this._loadFile.bind(this, file, width, height)); + () => this._loadFile()); themeContext.connectObject('notify::scale-factor', () => { - this._loadFile(file, width, height); - this.set_size(width * themeContext.scale_factor, height * themeContext.scale_factor); + this._loadFile(); + this.set_size( + this._width * themeContext.scale_factor, + this._height * themeContext.scale_factor); }, this); this._speed = speed; @@ -38,7 +44,7 @@ class Animation extends St.Bin { this._timeoutId = 0; this._frame = 0; - this._loadFile(file, width, height); + this._loadFile(); } play() { @@ -62,7 +68,7 @@ class Animation extends St.Bin { this._isPlaying = false; } - _loadFile(file, width, height) { + _loadFile() { const resourceScale = this.get_resource_scale(); let wasPlaying = this._isPlaying; @@ -74,7 +80,8 @@ class Animation extends St.Bin { let textureCache = St.TextureCache.get_default(); let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; - this._animations = textureCache.load_sliced_image(file, width, height, + this._animations = textureCache.load_sliced_image(this._file, + this._width, this._height, scaleFactor, resourceScale, () => this._loadFinished()); this._animations.set({