← Back to the site changelog
Site Changelog
Original commit record
Set homepage headline carousel to 2.5 seconds (#273)
- SHA
1fa4b2e93b7e6cce1e772ca2c20c5befb7434eb1
- Commit date
- Author
- nnneeeooo-nnneeeooo
- Committer
- web-flow
Changed files (5)
-
pipeline/build.py
modified · +1 / −1
-
static/app.js
modified · +1 / −1
-
templates/home.html
modified · +1 / −1
-
tests/test_headline_rotation.py
modified · +1 / −1
-
tests/test_mobile_layout.py
modified · +1 / −1
Full diff
@@ -1470,7 +1470,7 @@ def art_view(a, lang: str):\n \n \n \n-HERO_ROTATION_SECONDS = 8\n+HERO_ROTATION_SECONDS = 2.5\n _HERO_PIN_MAX_AGE = timedelta(hours=16)\n _HERO_FOCUS_FRESH_AGE = timedelta(hours=24)\n _HERO_FOCUS_FALLBACK_AGE = timedelta(days=7)\n@@ -212,7 +212,7 @@\n var reduceHeroMotion = window.matchMedia &&\n window.matchMedia("(prefers-reduced-motion: reduce)").matches;\n var heroTransitionMs = reduceHeroMotion ? 0 : 220;\n- var heroRotationMs = Number(heroCarousel && heroCarousel.dataset.rotationMs) || 8000;\n+ var heroRotationMs = Number(heroCarousel && heroCarousel.dataset.rotationMs) || 2500;\n \n function renderPriorityHero(story) {\n if (!story || !heroImage) return;\n@@ -47,7 +47,7 @@ <h6 style="margin:28px 0 12px;">{{ t.sourceStatus }}</h6>\n <div class="center-col">\n {% if hero %}\n <div id="hero-carousel" class="hero-carousel" role="region"\n- data-rotation-ms="{{ hero_rotation_seconds * 1000 }}"\n+ data-rotation-ms="{{ (hero_rotation_seconds * 1000)|int }}"\n aria-roledescription="carousel"\n aria-label="{% if html_lang.startswith('zh') %}頭條新聞輪播{% else %}Headline story carousel{% endif %}">\n <a id="hero-story-link" class="hero-story" href="{{ hero.url }}"{% if hero.external %} target="_blank" rel="noopener"{% endif %}>\n@@ -100,7 +100,7 @@ def test_rotation_payload_contains_localized_hero_fields():\n assert payload["kicker"] == "臺灣焦點 · 營運 · 短訊 — 頭條"\n assert payload["summary"] == "國籍航空調整航班。"\n assert "China Airlines Boeing 777-300ER" in payload["image_caption"]\n- assert build.HERO_ROTATION_SECONDS == 8\n+ assert build.HERO_ROTATION_SECONDS == 2.5\n \n view["focus"] = False\n global_payload = build.hero_rotation_view(view, "zh")\n@@ -128,7 +128,7 @@ def main() -> None:\n assert 'aria-roledescription="carousel"' in home_template\n assert 'aria-label="{% if html_lang.startswith(\'zh\') %}頭條新聞輪播' in home_template\n assert "hero-enter-right" in css\n- assert 'data-rotation-ms="8000"' in home\n+ assert 'data-rotation-ms="2500"' in home\n assert "dataset.rotationMs" in script\n assert 'addEventListener("mouseenter"' in script\n assert 'addEventListener("focusin"' in script