Animated cards: render guard to stop CSS animations restarting — v0.16.3 - #30
Merged
Merged
Conversation
Home Assistant pushes `hass` to every card on every state change, and the wind, rain, and lux cards rebuild their entire shadow-root innerHTML in _render on each push. Recreating the DOM restarts every CSS animation from the first frame, so the wind card's multi-second streak sweep snapped back to its start on every tick — a "bouncing line" across the compass rose. Rain (falling drops / wave) and lux (26s ray spin / disc pulse) had the same latent problem. Add a render guard: each card computes a signature of its displayed values and returns early from _render when nothing visible changed, so the DOM and its running animations persist across unrelated ticks. setConfig resets the signature to force a rebuild on config changes. VERSION 0.16.2 -> 0.16.3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014cpNPVU8j1iiU9CnXgr5JY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The wind card's animation showed "a bouncing line right in the wind rose" — the streak line kept snapping back to its start instead of sweeping smoothly across.
Cause
Home Assistant pushes
hassto every card on every state change (often several times a second). The wind, rain, and lux cards rebuild their entire shadow-rootinnerHTMLinsideset hass → _render(). Recreating the DOM restarts every CSS animation from frame 0 — so the wind streak's multi-second sweep never got to finish; it jumped back to the start on each unrelated tick, reading as a bouncing line. Rain (falling drops / wave) and lux (26s ray-spin / disc-pulse) had the same latent problem.Fix
A render guard: each card computes a signature of its displayed values and returns early from
_renderwhen nothing visible changed, so the DOM — and its running animations — persist across unrelated ticks.setConfigresets the signature so config edits still force a rebuild.speed / bearing / gust / unit / namefrac / event / intensity / periodChips / intLine / namevalue / night / band / name / unitTesting
bash build.sh+node test/smoke.jsgreen.hasspush skips the rebuild while a changed wind value still re-renders.VERSION 0.16.2 → 0.16.3.
🤖 Generated with Claude Code
Generated by Claude Code