Add a speaker view with a next-slide preview and keep the live slide in view
- 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:
1 parent
8262411225
commit
66ed198f87
11 files changed
+264
-5
No files matched your search
+41
-1
@@ -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) {
|
||||
var serialized = JSON.stringify(newState);
|
||||
if (serialized === last) {
|
||||
@@ -1328,6 +1346,7 @@
|
||||
last = serialized;
|
||||
state = newState;
|
||||
var slide = state.slide;
|
||||
renderNext(state.next);
|
||||
|
||||
setText('[data-counter]', state.count === 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() {
|
||||
return Fragments.request(window.location.href).then(function (doc) {
|
||||
Fragments.apply(doc, ['head', 'slides']);
|
||||
@@ -2735,7 +2768,14 @@
|
||||
nextId: next ? next.getAttribute('data-slide-id') : 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));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user