MCPcopy
hub / github.com/tmcw/big / go

Function go

lib/big.js:229–289  ·  view source on GitHub ↗

* The central navigation method: given a slide number, it goes to that slide * and sets it up. * * @param {number} n slide index * @param {boolean} dontSeek whether to seek audio. Specifically, when the slide * is changing _because_ of audio tracks, we don't also want to skip audio.

(n, dontSeek, force)

Source from the content-addressed store, hash-verified

227 * is changing _because_ of audio tracks, we don't also want to skip audio.
228 */
229 function go(n, dontSeek, force) {
230 // Ensure that the slide we're going to is in range: it isn't
231 // less than 0 or higher than the actual number of slides available.
232 n = Math.max(0, Math.min(big.length - 1, n));
233 // Avoid doing extra work if we're going from a slide to itself.
234 if (!force && big.current === n) return;
235 big.current = n;
236 var slideContainer = slideDivs[n];
237 var slideDiv = slideContainer.firstChild;
238 printNotesToConsole(n);
239
240 if (!dontSeek) {
241 goToAudio(n);
242 }
243
244 slideDivs.forEach(function(slide, i) {
245 slide.style.display = i === n ? "flex" : "none";
246 });
247
248 body.className =
249 "talk-mode " +
250 (slideDiv.getAttribute("data-bodyclass") || "") +
251 " " +
252 initialBodyClass;
253
254 useDataImageAsBackground(slideContainer);
255
256 // If a previous slide had set a timer to auto-advance but
257 // the user navigated before it fired, cancel it.
258 if (timeoutInterval !== undefined) {
259 window.clearInterval(timeoutInterval);
260 }
261
262 // If this slide has a time-to-next data attribute, set a
263 // timer that advances to the next slide within that many
264 // seconds.
265 if (slideDiv.hasAttribute("data-time-to-next")) {
266 if (big.audio) {
267 throw new Error(
268 "this presentation uses an audio track, and also uses time-to-next. " +
269 "You must only use one or the other."
270 );
271 }
272 var timeToNextStr = slideDiv.getAttribute("data-time-to-next");
273 var timeToNext = parseFloat(timeToNextStr);
274 if (isNaN(timeToNext)) {
275 throw new Error(
276 "big encountered a bad value for the time-to-next string: " +
277 timeToNextStr
278 );
279 }
280 timeoutInterval = window.setTimeout(forward, timeToNext * 1000);
281 }
282
283 slideDiv.focus();
284 onResize();
285 if (window.location.hash !== n) {
286 window.location.hash = n;

Callers 7

big.jsFile · 0.85
forwardFunction · 0.85
reverseFunction · 0.85
onTalkFunction · 0.85
onClickFunction · 0.85
onAudioUpdateFunction · 0.85
onHashChangeFunction · 0.85

Calls 4

printNotesToConsoleFunction · 0.85
goToAudioFunction · 0.85
useDataImageAsBackgroundFunction · 0.85
onResizeFunction · 0.85

Tested by

no test coverage detected