feat(showcase): add ability to disable start animation

This commit is contained in:
Haoyu Xu
2023-06-23 09:32:04 -04:00
parent 821970e05c
commit 20f23aa31e
2 changed files with 19 additions and 2 deletions

View File

@@ -30,10 +30,10 @@ export default function spinePlayer(el) {
fps: 60, fps: 60,
defaultMix: 0, defaultMix: 0,
success: function (widget) { success: function (widget) {
if (widget.skeleton.data.animations.map(e => e.name).includes("Start")) { if (widget.skeleton.data.animations.map(e => e.name).includes("Start") && window.settings.useStartAnimation) {
widget.animationState.setAnimation(0, "Start", false, 0) widget.animationState.setAnimation(0, "Start", false, 0)
widget.animationState.addAnimation(0, "Idle", true, 0);
} }
widget.animationState.addAnimation(0, "Idle", true, 0);
widget.animationState.addListener({ widget.animationState.addListener({
end: (e) => { end: (e) => {
if (e.animation.name == "Interact") { if (e.animation.name == "Interact") {

View File

@@ -40,6 +40,7 @@ export default class Settings {
#isInsightsInited = false #isInsightsInited = false
#doNotTrack = false #doNotTrack = false
#lastFunctionInsights = null #lastFunctionInsights = null
#useStartAnimation = true
constructor(el, logoEl) { constructor(el, logoEl) {
this.isWallpaperEngine = false this.isWallpaperEngine = false
@@ -283,6 +284,14 @@ export default class Settings {
document.getElementById("logo_padding_y_input").value = this.#defaultLogoY document.getElementById("logo_padding_y_input").value = this.#defaultLogoY
} }
set useStartAnimation(v) {
this.#useStartAnimation = v
}
get useStartAnimation() {
return this.#useStartAnimation
}
open() { open() {
this.#el.hidden = false; this.#el.hidden = false;
} }
@@ -459,6 +468,10 @@ export default class Settings {
<label for="animation_select">Animation:</label> <label for="animation_select">Animation:</label>
<select name="animation_select" id="animation_selection"></select> <select name="animation_select" id="animation_selection"></select>
</div> </div>
<div>
<label for="use_start_animation">Use Start Animation</label>
<input type="checkbox" id="use_start_animation" name="use_start_animation" checked/>
</div>
<div> <div>
<button type="button" id="settings_play" disabled>Play</button> <button type="button" id="settings_play" disabled>Play</button>
<button type="button" id="settings_pause">Pause</button> <button type="button" id="settings_pause">Pause</button>
@@ -717,6 +730,10 @@ export default class Settings {
this.spinePlayer.animationState.setAnimation(0, e.currentTarget.value, false, 0) this.spinePlayer.animationState.setAnimation(0, e.currentTarget.value, false, 0)
this.spinePlayer.animationState.addAnimation(0, "Idle", true, 0); this.spinePlayer.animationState.addAnimation(0, "Idle", true, 0);
} }
}, {
id: "use_start_animation", event: "click", handler: e => {
this.#useStartAnimation = e.currentTarget.checked;
}
}, },
] ]