Add a speaker view with a next-slide preview and keep the live slide in view
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

- New /admin/{token}/speaker page for a second window: current slide, preview of
  the next slide and the usual controls. It does not start the presentation.
- The presenter state gets `next` (labels only, no solutions).
- The dashboard scrolls the live slide into view when the presenter moves on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 15:43:49 +01:00
1 parent 8262411225
commit 66ed198f87
11 files changed
+264 -5

No files matched your search

+1 -1
View File
@@ -53,7 +53,7 @@ passende Dokument und pflegt es danach** (Details zu Verhalten, Settings, Tests
| Verzeichnisstruktur, Klassen, Tabellen | [docs/architecture.md](docs/architecture.md) | | Verzeichnisstruktur, Klassen, Tabellen | [docs/architecture.md](docs/architecture.md) |
| Folientypen (Wortwolke, Quiz, Q&A, Reihenfolge, YouTube, Skala/Sterne, Kommentare), Checkliste „Neuen Folientyp hinzufügen“ | [docs/slide-types.md](docs/slide-types.md) | | Folientypen (Wortwolke, Quiz, Q&A, Reihenfolge, YouTube, Skala/Sterne, Kommentare), Checkliste „Neuen Folientyp hinzufügen“ | [docs/slide-types.md](docs/slide-types.md) |
| Folienbilder (Upload, Ablage, Löschen) | [docs/images.md](docs/images.md) | | Folienbilder (Upload, Ablage, Löschen) | [docs/images.md](docs/images.md) |
| Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) | | Live-Schaltung, Referentenansicht, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) |
| Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild | [docs/frontend.md](docs/frontend.md) | | Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild | [docs/frontend.md](docs/frontend.md) |
| PDF-Export | [docs/pdf-export.md](docs/pdf-export.md) | | PDF-Export | [docs/pdf-export.md](docs/pdf-export.md) |
| Ablauf/Cleanup von Umfragen, CI/Deploy, Releases, Docker | [docs/operations.md](docs/operations.md) | | Ablauf/Cleanup von Umfragen, CI/Deploy, Releases, Docker | [docs/operations.md](docs/operations.md) |
+1
View File
@@ -76,6 +76,7 @@ return function (RouteBuilder $routes): void {
$admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete']) $admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete'])
->setPatterns($token)->setMethods(['POST']); ->setPatterns($token)->setMethods(['POST']);
$admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token); $admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token);
$admin->connect('/speaker', 'Admin::speaker', ['_name' => 'admin:speaker'])->setPatterns($token);
$admin->connect('/state', 'Admin::state', ['_name' => 'admin:state'])->setPatterns($token); $admin->connect('/state', 'Admin::state', ['_name' => 'admin:state'])->setPatterns($token);
$admin->connect('/live', 'Admin::live', ['_name' => 'admin:live'])->setPatterns($token); $admin->connect('/live', 'Admin::live', ['_name' => 'admin:live'])->setPatterns($token);
$admin->connect('/control', 'Admin::control', ['_name' => 'admin:control']) $admin->connect('/control', 'Admin::control', ['_name' => 'admin:control'])
+2 -1
View File
@@ -12,7 +12,8 @@ Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild. CSP-Regeln stehen i
zurück (Dialog bleibt offen), Erfolg als Dashboard-Fragment (Dialog schließt). Ohne JS funktioniert alles als normale Seite. zurück (Dialog bleibt offen), Erfolg als Dashboard-Fragment (Dialog schließt). Ohne JS funktioniert alles als normale Seite.
Die Liste folgt auch dem Presenter (Live-Markierung, Status): `initAdminDashboard()` pollt `admin:live` (`AdminController::live()`, Die Liste folgt auch dem Presenter (Live-Markierung, Status): `initAdminDashboard()` pollt `admin:live` (`AdminController::live()`,
nur `{version}` aus `PollStateService::dashboardVersion()`, billiger als der Presenter-State) und lädt `head`/`slides` nur bei geänderter Version nur `{version}` aus `PollStateService::dashboardVersion()`, billiger als der Presenter-State) und lädt `head`/`slides` nur bei geänderter Version
neu – nie bei offenem Dialog, laufender Anfrage oder Drag & Drop; der Fokus wird wiederhergestellt. Test: `PollResetTest::testDashboardLiveVersionFollowsThePresenter`. neu – nie bei offenem Dialog, laufender Anfrage oder Drag & Drop; der Fokus wird wiederhergestellt. Wechselt dabei die Live-Folie, scrollt `revealCurrent()` sie per `scrollIntoView({block: 'nearest'})` in den
sichtbaren Bereich (bei langen Listen; bewegt nichts, wenn sie schon sichtbar ist; ohne Animation bei `prefers-reduced-motion`). Test: `PollResetTest::testDashboardLiveVersionFollowsThePresenter`.
**Buttons mit Bestätigung** nutzen `Form->postButton()` + `data-confirm` (CakePHPs `postLink`/`confirm` erzeugt ein Inline-`onclick`, **Buttons mit Bestätigung** nutzen `Form->postButton()` + `data-confirm` (CakePHPs `postLink`/`confirm` erzeugt ein Inline-`onclick`,
das die CSP blockiert); das JS fragt per `window.confirm()` vor dem Absenden. Tests: `AdminFragmentTest.php`. das die CSP blockiert); das JS fragt per `window.confirm()` vor dem Absenden. Tests: `AdminFragmentTest.php`.
+9
View File
@@ -7,6 +7,15 @@ Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung und an
Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/state`) pollen per `fetch` Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/state`) pollen per `fetch`
(`Plenario.pollIntervalMs`). Die Teilnehmerseite lädt neu, wenn sich `version` im State ändert. (`Plenario.pollIntervalMs`). Die Teilnehmerseite lädt neu, wenn sich `version` im State ändert.
## Referentenansicht
- `/admin/{token}/speaker` (`admin:speaker`, Button ⧉ im Präsentationsmodus und Link „Referentenansicht“ neben „Präsentieren“ in der Verwaltung, jeweils neues Fenster) ist für den eigenen Bildschirm des
Präsentierenden: gleiche Seite und gleiches JS wie `present` (`initPresenter`, Steuerung per Tasten/Buttons), plus
`data-next`-Kasten „Als Nächstes“ links neben der aktuellen Folie (`stage--speaker`). Anders als `present` startet sie die Präsentation nicht.
- Datenquelle ist `next` im Presenter-State (`PollStateService::nextPreview()`): Folie hinter der Live-Folie (ausgeblendete werden übersprungen),
bei Pause die pausierte, vor dem Start die erste, `null` nach der letzten. Nur Beschriftungen – nie `is_correct`, bei Reihenfolge keine Optionen
(die gespeicherte Reihenfolge ist die Lösung). Tests: `SpeakerViewTest.php`.
## Pause ## Pause
- **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne - **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne
+23 -1
View File
@@ -169,7 +169,16 @@ class AdminController extends AdminAppController
*/ */
public function present(): void public function present(): void
{ {
if ($this->poll->current_slide_id === null && !$this->poll->isPaused()) { $this->prepareStage(true);
}
/**
* @param bool $start Show the first slide if the presentation has not been started yet
* @return void
*/
private function prepareStage(bool $start): void
{
if ($start && $this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$first = $this->Slides->find() $first = $this->Slides->find()
->where(['poll_id' => $this->poll->id, 'is_hidden' => false]) ->where(['poll_id' => $this->poll->id, 'is_hidden' => false])
->orderBy(['position' => 'ASC', 'id' => 'ASC']) ->orderBy(['position' => 'ASC', 'id' => 'ASC'])
@@ -186,6 +195,19 @@ class AdminController extends AdminAppController
$this->setPollInterval(); $this->setPollInterval();
} }
/**
* Speaker view for a second window or screen: current slide, preview of the next one and the
* same controls as the presenter screen. Unlike present() it never starts the presentation.
*
* @return void
*/
public function speaker(): void
{
$this->prepareStage(false);
$this->set('speaker', true);
$this->viewBuilder()->setTemplate('present');
}
/** /**
* JSON state for the presenter screen. * JSON state for the presenter screen.
* *
+39
View File
@@ -131,12 +131,51 @@ class PollStateService
], $slides), ], $slides),
'index' => $index, 'index' => $index,
'count' => count($slides), 'count' => count($slides),
'next' => $this->nextPreview($poll, $slides, $index),
'hiddenCount' => $this->Slides->find()->where(['poll_id' => $poll->id, 'is_hidden' => true])->count(), 'hiddenCount' => $this->Slides->find()->where(['poll_id' => $poll->id, 'is_hidden' => true])->count(),
'slide' => $current ? $this->slidePayload($current, $poll) : null, 'slide' => $current ? $this->slidePayload($current, $poll) : null,
'results' => $current ? $this->results->forSlide($current) : null, 'results' => $current ? $this->results->forSlide($current) : null,
]; ];
} }
/**
* Preview of the slide that comes next for the speaker view: the one behind the live slide, the
* paused one while paused (that is where "continue" goes), the first one before the start.
* Labels only: never `is_correct` and never the options of an order slide (they are stored in the
* correct order), so nothing leaks that is not allowed in the JSON before the slide is resolved.
*
* @param \App\Model\Entity\Poll $poll Poll
* @param list<\App\Model\Entity\Slide> $slides Visible slides in presentation order
* @param int|null $index Index of the live slide in `$slides`
* @return array<string, mixed>|null Null after the last slide
*/
private function nextPreview(Poll $poll, array $slides, ?int $index): ?array
{
if ($index !== null) {
$next = $slides[$index + 1] ?? null;
} else {
$next = $slides[0] ?? null;
foreach ($slides as $slide) {
if ($poll->paused_slide_id !== null && $slide->id === $poll->paused_slide_id) {
$next = $slide;
}
}
}
if ($next === null) {
return null;
}
return [
'id' => $next->id,
'type' => $next->type,
'typeLabel' => $next->typeLabel(),
'question' => $next->question,
'description' => (string)$next->description,
'options' => $next->isOrder() ? [] : array_map(fn($o) => $o->label, $next->slide_options ?? []),
'hasImage' => $next->hasImage(),
];
}
/** /**
* State of one embedded slide (/e/{key}/{slide}/state). Same shape as forPresenter(), * State of one embedded slide (/e/{key}/{slide}/state). Same shape as forPresenter(),
* but always for this slide, live or not, plus `isLive`. Never contains the slide list. * but always for this slide, live or not, plus `isLive`. Never contains the slide list.
+2
View File
@@ -37,6 +37,8 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
<div class="admin-head__actions"> <div class="admin-head__actions">
<a class="button button--primary" target="_blank" rel="noopener" <a class="button button--primary" target="_blank" rel="noopener"
href="<?= $this->Url->build($url('admin:present')) ?>">▶ <?= __('Präsentieren') ?></a> href="<?= $this->Url->build($url('admin:present')) ?>">▶ <?= __('Präsentieren') ?></a>
<a class="button" target="_blank" rel="noopener" href="<?= $this->Url->build($url('admin:speaker')) ?>"
title="<?= h(__('Eigenes Fenster für den Präsentierenden: aktuelle und nächste Folie, ohne die Präsentation zu starten')) ?>">⧉ <?= __('Referentenansicht') ?></a>
<?php if ($poll->current_slide_id !== null) : ?> <?php if ($poll->current_slide_id !== null) : ?>
<?= $this->Form->postButton('⏸ ' . __('Pause'), $url('admin:control'), [ <?= $this->Form->postButton('⏸ ' . __('Pause'), $url('admin:control'), [
'data' => ['action' => 'stop'], 'data' => ['action' => 'stop'],
+20 -1
View File
@@ -4,6 +4,7 @@
* (Plenario.presenter) from /admin/{token}/state. * (Plenario.presenter) from /admin/{token}/state.
* *
* Keyboard: ←/→ slides, P pause/resume (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark. * Keyboard: ←/→ slides, P pause/resume (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark.
* The speaker view (admin:speaker) is this page plus a preview of the next slide, meant for the presenter's own screen.
* Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first. * Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first.
* *
* @var \App\View\AppView $this * @var \App\View\AppView $this
@@ -12,11 +13,13 @@
* @var string $joinUrl * @var string $joinUrl
* @var string $joinBaseUrl * @var string $joinBaseUrl
* @var int $pollIntervalMs * @var int $pollIntervalMs
* @var bool|null $speaker Speaker view (second window): adds the preview of the next slide
*/ */
$speaker = $speaker ?? false;
$this->assign('title', $poll->title); $this->assign('title', $poll->title);
$host = preg_replace('#^https?://#', '', $joinBaseUrl); $host = preg_replace('#^https?://#', '', $joinBaseUrl);
?> ?>
<div class="stage" <div class="stage<?= $speaker ? ' stage--speaker' : '' ?>"
data-presenter data-presenter
data-state-url="<?= $this->Url->build(['_name' => 'admin:state', 'token' => $adminToken]) ?>" data-state-url="<?= $this->Url->build(['_name' => 'admin:state', 'token' => $adminToken]) ?>"
data-control-url="<?= $this->Url->build(['_name' => 'admin:control', 'token' => $adminToken]) ?>" data-control-url="<?= $this->Url->build(['_name' => 'admin:control', 'token' => $adminToken]) ?>"
@@ -42,8 +45,24 @@ $host = preg_replace('#^https?://#', '', $joinBaseUrl);
<div class="stage__results" data-results></div> <div class="stage__results" data-results></div>
</main> </main>
<?php if ($speaker) : ?>
<aside class="stage__next" data-next aria-label="<?= h(__('Nächste Folie')) ?>">
<p class="stage__next-label"><?= __('Als Nächstes') ?> <span data-next-meta></span></p>
<h2 class="stage__next-question" data-next-question></h2>
<div class="stage__next-description formatted" data-next-description></div>
<ul class="stage__next-options" data-next-options></ul>
<p class="stage__next-note muted" data-next-note></p>
</aside>
<?php endif; ?>
<footer class="stage__controls"> <footer class="stage__controls">
<a class="ctrl" href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>" title="<?= __('Zur Verwaltung') ?>">✎</a> <a class="ctrl" href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>" title="<?= __('Zur Verwaltung') ?>">✎</a>
<?php if (!$speaker) : ?>
<a class="ctrl" href="<?= $this->Url->build(['_name' => 'admin:speaker', 'token' => $adminToken]) ?>" target="_blank" rel="noopener"
title="<?= __('Referentenansicht in neuem Fenster öffnen (mit Vorschau der nächsten Folie)') ?>">
<span aria-hidden="true">⧉</span><span class="sr-only"><?= __('Referentenansicht öffnen') ?></span>
</a>
<?php endif; ?>
<button type="button" class="ctrl" data-action="prev" aria-keyshortcuts="ArrowLeft PageUp" title="<?= __('Vorherige Folie (←)') ?>"> <button type="button" class="ctrl" data-action="prev" aria-keyshortcuts="ArrowLeft PageUp" title="<?= __('Vorherige Folie (←)') ?>">
<span aria-hidden="true">←</span><span class="sr-only"><?= __('Vorherige Folie') ?></span> <span aria-hidden="true">←</span><span class="sr-only"><?= __('Vorherige Folie') ?></span>
</button> </button>
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Controller;
use App\Model\Entity\Slide;
use App\Test\TestCase\PlenarioTestTrait;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* Speaker view (second window): preview of the next slide, no side effects, no solutions in the JSON.
*/
class SpeakerViewTest extends TestCase
{
use IntegrationTestTrait;
use PlenarioTestTrait;
/**
* @var list<string>
*/
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
protected function setUp(): void
{
parent::setUp();
$this->enableCsrfToken();
}
/**
* @return array<string, mixed>
*/
protected function state(string $token): array
{
$this->get("/admin/$token/state");
$this->assertResponseOk();
return json_decode((string)$this->_response->getBody(), true);
}
public function testSpeakerPageDoesNotStartThePresentation(): void
{
[$poll, $token] = $this->createPoll();
$this->createSlide($poll, Slide::TYPE_CHOICE);
for ($i = 0; $i < 2; $i++) {
$this->get("/admin/$token/speaker");
$this->assertResponseOk();
$this->assertResponseContains('data-next');
$this->assertNull($this->pollsTable()->get($poll->id)->current_slide_id);
}
$this->get("/admin/$token/present");
$this->assertResponseNotContains('data-next-question');
}
public function testSpeakerPageNeedsTheToken(): void
{
$this->get('/admin/' . str_repeat('x', 30) . '/speaker');
$this->assertResponseCode(404);
}
public function testNextIsTheSlideBehindTheLiveOne(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CHOICE);
$second = $this->createSlide($poll, Slide::TYPE_CHOICE, ['question' => 'Zweite?']);
$hidden = $this->createSlide($poll, Slide::TYPE_CONTENT);
$hidden->is_hidden = true;
$this->slidesTable()->saveOrFail($hidden);
$this->createSlide($poll, Slide::TYPE_WORDCLOUD, ['question' => 'Letzte?']);
$this->assertSame($first->id, $this->state($token)['next']['id'], 'before the start: the first slide');
$this->goLive($poll, $first);
$next = $this->state($token)['next'];
$this->assertSame($second->id, $next['id']);
$this->assertSame('Zweite?', $next['question']);
$this->assertSame(['Ja', 'Nein'], $next['options']);
$this->goLive($poll, $second);
$this->assertSame('Letzte?', $this->state($token)['next']['question'], 'hidden slides are skipped');
$last = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_WORDCLOUD])->firstOrFail();
$this->goLive($poll, $last);
$this->assertNull($this->state($token)['next'], 'nothing after the last slide');
}
public function testPreviewRevealsNoSolution(): void
{
[$poll, $token] = $this->createPoll();
$first = $this->createSlide($poll, Slide::TYPE_CONTENT);
$this->createSlide($poll, Slide::TYPE_QUIZ, [], ['Richtig', 'Falsch']);
$this->createSlide($poll, Slide::TYPE_ORDER, [], ['Eins', 'Zwei', 'Drei']);
$this->goLive($poll, $first);
$quiz = $this->state($token)['next'];
$this->assertSame(['Richtig', 'Falsch'], $quiz['options']);
$this->assertStringNotContainsString('is_correct', json_encode($quiz));
$order = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_ORDER])->firstOrFail();
$quizSlide = $this->slidesTable()->find()->where(['poll_id' => $poll->id, 'type' => Slide::TYPE_QUIZ])->firstOrFail();
$this->goLive($poll, $quizSlide);
$this->assertSame([], $this->state($token)['next']['options'], 'the stored order is the solution');
$this->assertSame($order->id, $this->state($token)['next']['id']);
}
}
+19
View File
@@ -678,6 +678,25 @@ body.present {
--star: #d48500; --star: #d48500;
--star-empty: #c3c8da; --star-empty: #c3c8da;
} }
/* Speaker view (second window): current slide left, preview of the next one right. */
.stage--speaker { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: auto 1fr auto; column-gap: 3vw; }
.stage--speaker > .stage__top, .stage--speaker > .stage__controls { grid-column: 1 / -1; }
.stage--speaker .stage__question { font-size: clamp(1.5rem, 3vw, 2.6rem); }
.stage--speaker .stage__description { font-size: clamp(1rem, 1.5vw, 1.3rem); }
.stage--speaker .stage__results { font-size: clamp(.9rem, 1.3vw, 1.2rem); }
.stage__next { align-self: center; max-height: 100%; overflow: auto; padding: 2vh 2vw; border: 1px dashed rgba(var(--tint), .3); border-radius: 12px; background: rgba(var(--tint), .05); }
.stage__next-label { text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; font-size: .85rem; margin: 0 0 .6em; }
.stage__next-question { font-size: clamp(1.2rem, 2.2vw, 2rem); margin: 0 0 .4em; }
.stage__next-description { color: var(--muted); font-size: clamp(.95rem, 1.3vw, 1.15rem); margin: 0 0 .8em; }
.stage__next-description:empty, .stage__next-options:empty, .stage__next-note:empty { display: none; }
.stage__next-options { margin: 0 0 .8em; padding-left: 1.2em; font-size: clamp(.95rem, 1.3vw, 1.15rem); }
.stage__next-note { margin: 0; font-size: .9rem; }
.stage__next--end .stage__next-question { color: var(--muted); font-weight: 400; }
@media (max-width: 800px) {
body.present:has(.stage--speaker) { overflow: auto; }
.stage--speaker { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; height: auto; min-height: 100vh; }
.stage__next { align-self: stretch; margin-bottom: 2vh; }
}
.stage__top { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: clamp(1rem, 1.6vw, 1.4rem); color: var(--muted); } .stage__top { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: clamp(1rem, 1.6vw, 1.4rem); color: var(--muted); }
.stage__top strong { color: var(--text); } .stage__top strong { color: var(--text); }
.stage__code { letter-spacing: .12em; background: rgba(var(--tint), .1); padding: 2px 10px; border-radius: 8px; } .stage__code { letter-spacing: .12em; background: rgba(var(--tint), .1); padding: 2px 10px; border-radius: 8px; }
+41 -1
View File
@@ -1320,6 +1320,24 @@
} }
} }
/** Speaker view: preview of the slide that "next" will show (labels only, the server sends no solutions). */
function renderNext(next) {
var box = q('[data-next]');
if (!box) {
return;
}
var options = q('[data-next-options]');
options.textContent = '';
setText('[data-next-meta]', next ? '· ' + next.typeLabel : '');
setText('[data-next-question]', next ? next.question : 'Das war die letzte Folie');
Format.render(q('[data-next-description]'), next ? next.description : '');
(next ? next.options : []).forEach(function (label) {
options.appendChild(el('li', { text: label }));
});
setText('[data-next-note]', next && next.hasImage ? 'Die Folie enthält ein Bild.' : '');
box.classList.toggle('stage__next--end', !next);
}
function render(newState) { function render(newState) {
var serialized = JSON.stringify(newState); var serialized = JSON.stringify(newState);
if (serialized === last) { if (serialized === last) {
@@ -1328,6 +1346,7 @@
last = serialized; last = serialized;
state = newState; state = newState;
var slide = state.slide; var slide = state.slide;
renderNext(state.next);
setText('[data-counter]', state.count === 0 setText('[data-counter]', state.count === 0
? '0 / 0' ? '0 / 0'
@@ -2704,6 +2723,20 @@
} }
} }
function currentSlideId() {
var current = document.querySelector('.slide-item--current');
return current ? current.getAttribute('data-slide-id') : null;
}
/** Scrolls the live slide into view if it is outside (no movement if it is already visible). */
function revealCurrent() {
var current = document.querySelector('.slide-item--current');
if (current) {
var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
current.scrollIntoView({ block: 'nearest', behavior: calm ? 'auto' : 'smooth' });
}
}
function refreshList() { function refreshList() {
return Fragments.request(window.location.href).then(function (doc) { return Fragments.request(window.location.href).then(function (doc) {
Fragments.apply(doc, ['head', 'slides']); Fragments.apply(doc, ['head', 'slides']);
@@ -2735,7 +2768,14 @@
nextId: next ? next.getAttribute('data-slide-id') : null nextId: next ? next.getAttribute('data-slide-id') : null
} : null; } : null;
return refreshList().then(function () { restoreFocus(target); }); var liveBefore = currentSlideId();
return refreshList().then(function () {
restoreFocus(target);
// The presenter moved on: keep the live slide in view on long lists.
if (currentSlideId() !== liveBefore) {
revealCurrent();
}
});
}); });
}, Math.max(4000, parseInt(liveRoot.getAttribute('data-interval'), 10) * 2 || 4000)); }, Math.max(4000, parseInt(liveRoot.getAttribute('data-interval'), 10) * 2 || 4000));
} }