mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +08:00
News ticker: constant scroll speed
Derive the animation duration from the distance travelled instead of the item count, so wide screens no longer scroll faster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
94b290fa06
commit
3c24ddc7d3
1 file changed
+8
-1
+8
-1
@@ -2658,7 +2658,14 @@ function NewsTicker() {
|
|||||||
<div className="ts-news-ticker">
|
<div className="ts-news-ticker">
|
||||||
<span className="ts-news-label">{t("news.label")}</span>
|
<span className="ts-news-label">{t("news.label")}</span>
|
||||||
<div className="ts-news-track">
|
<div className="ts-news-track">
|
||||||
<div className="ts-news-scroll" style={{ animationDuration: `${Math.max(20, items.length * 12)}s` }}>
|
{/* Duration from the distance travelled (track + text), so the speed is
|
||||||
|
the same ~60 px/s on every screen width. */}
|
||||||
|
<div
|
||||||
|
className="ts-news-scroll"
|
||||||
|
ref={(el) => {
|
||||||
|
if (el) el.style.animationDuration = `${el.scrollWidth / 60}s`;
|
||||||
|
}}
|
||||||
|
>
|
||||||
{entries}
|
{entries}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user