[WV2] Fix syncing for play/pause state across page morphs
Reproduce: 1. Add an item with animations, and play them. 2. Remove the item. 3. Add it back. 4. Observe the button shows up in "Paused" state, even though it's playing. This is because the server-side template wasn't doing anything to try to keep the play/pause button it renders in sync with the current saved state in the cookies, so it was always causing a morph to the pause state. Now we listen to the cookie instead! I also updated the JS behavior to be a bit more consistent: treat the behavior as defaulting to true, unless it's explicitly set to the string "false".
This commit is contained in:
parent
ff3dd2249e
commit
5e68d3809c
2 changed files with 2 additions and 2 deletions
|
|
@ -145,7 +145,7 @@ class OutfitViewer extends HTMLElement {
|
||||||
.split("; ")
|
.split("; ")
|
||||||
.find((row) => row.startsWith("DTIOutfitViewerIsPlaying="));
|
.find((row) => row.startsWith("DTIOutfitViewerIsPlaying="));
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
return cookie.split("=")[1] === "true";
|
return cookie.split("=")[1] !== "false";
|
||||||
}
|
}
|
||||||
return true; // Default to playing
|
return true; // Default to playing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
.preview-controls-top
|
.preview-controls-top
|
||||||
%outfit-viewer-play-pause-toggle{for: "wardrobe-outfit-viewer"}
|
%outfit-viewer-play-pause-toggle{for: "wardrobe-outfit-viewer"}
|
||||||
%label.play-pause-control-button.button
|
%label.play-pause-control-button.button
|
||||||
%input{type: "checkbox"}
|
%input{type: "checkbox", checked: cookies[:DTIOutfitViewerIsPlaying] != "false"}
|
||||||
%span.paused-label Paused
|
%span.paused-label Paused
|
||||||
%span.playing-label Playing
|
%span.playing-label Playing
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue