From 87d9bfd092c188dc450d5fdf23f1c43a04a7e335 Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Tue, 31 Jan 2023 10:31:27 -0500 Subject: [PATCH] fix(showcase): fixed an issue where the position wouldn't load in wallpaper engine --- .gitignore | 1 + libs/content_processor.js | 10 +-------- src/components/player.js | 1 + src/components/settings.js | 40 +++++++++++++++--------------------- src/libs/wallpaper_engine.js | 7 +++++++ 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 98bc422..f8757e1 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ dist-ssr *.njsproj *.sln *.sw? +temp diff --git a/libs/content_processor.js b/libs/content_processor.js index 7807467..4a37c1d 100644 --- a/libs/content_processor.js +++ b/libs/content_processor.js @@ -24,15 +24,7 @@ export default class Matcher { 'assets', `return new Evalable(config, assets).${name}`) )(Evalable, this.#config, this.#assets) - if (matches.length > 1) { - try { - this.content = this.content.replace(match, result) - } catch (e) { - throw new Error(e) - } - } else if (matches.length === 1) { - this.content = result - } + this.content = matches.length > 1 ? this.content.replace(match, result) : result }) } return this.content diff --git a/src/components/player.js b/src/components/player.js index a151a1f..b77cc82 100644 --- a/src/components/player.js +++ b/src/components/player.js @@ -55,6 +55,7 @@ export default function spinePlayer(el) { entry.mixDuration = 0.3; widget.animationState.addAnimation(0, "Idle", true, 0); } + window.settings.loadViewport() }, }) } \ No newline at end of file diff --git a/src/components/settings.js b/src/components/settings.js index 8e882e8..a0b0982 100644 --- a/src/components/settings.js +++ b/src/components/settings.js @@ -150,45 +150,37 @@ export default class Settings { document.getElementById("custom_background_clear").disabled = true } + loadViewport() { + this.spinePlayer.updateViewport({ + padLeft: `${this.#padLeft}%`, + padRight: `${this.#padRight}%`, + padTop: `${this.#padTop}%`, + padBottom: `${this.#padBottom}%`, + }) + } + positionPadding(key, value) { switch (key) { case "left": this.#padLeft = value - this.spinePlayer.updateViewport({ - padLeft: `${value}%`, - padRight: `${this.#padRight}%`, - padTop: `${this.#padTop}%`, - padBottom: `${this.#padBottom}%`, - }) break; case "right": this.#padRight = value - this.spinePlayer.updateViewport({ - padLeft: `${this.#padLeft}%`, - padRight: `${value}%`, - padTop: `${this.#padTop}%`, - padBottom: `${this.#padBottom}%`, - }) break; case "top": this.#padTop = value - this.spinePlayer.updateViewport({ - padLeft: `${this.#padLeft}%`, - padRight: `${this.#padRight}%`, - padTop: `${value}%`, - padBottom: `${this.#padBottom}%`, - }) break; case "bottom": this.#padBottom = value - this.spinePlayer.updateViewport({ - padLeft: `${this.#padLeft}%`, - padRight: `${this.#padRight}%`, - padTop: `${this.#padTop}%`, - padBottom: `${value}%`, - }) + break; + default: + this.#padLeft = value.left + this.#padRight = value.right + this.#padTop = value.top + this.#padBottom = value.bottom break; } + this.loadViewport() } positionReset() { diff --git a/src/libs/wallpaper_engine.js b/src/libs/wallpaper_engine.js index 1794b76..a837fca 100644 --- a/src/libs/wallpaper_engine.js +++ b/src/libs/wallpaper_engine.js @@ -40,6 +40,13 @@ window.wallpaperPropertyListener = { if (properties.position) { if (!properties.position.value) { window.settings.positionReset() + } else { + window.settings.positionPadding(null, { + left: properties.paddingleft.value, + right: properties.paddingright.value, + top: properties.paddingtop.value, + bottom: properties.paddingbottom.value, + }) } } if (properties.paddingleft) {