MCPcopy
hub / github.com/hakimel/reveal.js / syncPages

Method syncPages

js/controllers/scrollview.js:280–417  ·  view source on GitHub ↗

* Updates our pages to match the latest configuration and * presentation size.

()

Source from the content-addressed store, hash-verified

278 * presentation size.
279 */
280 syncPages() {
281
282 const config = this.Reveal.getConfig();
283
284 const slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
285 const scale = this.Reveal.getScale();
286 const useCompactLayout = config.scrollLayout === 'compact';
287
288 const viewportHeight = this.viewportElement.offsetHeight;
289 const compactHeight = slideSize.height * scale;
290 const pageHeight = useCompactLayout ? compactHeight : viewportHeight;
291
292 // The height that needs to be scrolled between scroll triggers
293 this.scrollTriggerHeight = useCompactLayout ? compactHeight : viewportHeight;
294
295 this.viewportElement.style.setProperty( '--page-height', pageHeight + 'px' );
296 this.viewportElement.style.scrollSnapType = typeof config.scrollSnap === 'string' ? `y ${config.scrollSnap}` : '';
297
298 // This will hold all scroll triggers used to show/hide slides
299 this.slideTriggers = [];
300
301 const pageElements = Array.from( this.Reveal.getRevealElement().querySelectorAll( '.scroll-page' ) );
302
303 this.pages = pageElements.map( pageElement => {
304 const page = this.createPage({
305 pageElement,
306 slideElement: pageElement.querySelector( 'section' ),
307 stickyElement: pageElement.querySelector( '.scroll-page-sticky' ),
308 contentElement: pageElement.querySelector( '.scroll-page-content' ),
309 backgroundElement: pageElement.querySelector( '.slide-background' ),
310 autoAnimateElements: pageElement.querySelectorAll( '.scroll-auto-animate-page' ),
311 autoAnimatePages: []
312 });
313
314 page.pageElement.style.setProperty( '--slide-height', config.center === true ? 'auto' : slideSize.height + 'px' );
315
316 this.slideTriggers.push({
317 page: page,
318 activate: () => this.activatePage( page ),
319 deactivate: () => this.deactivatePage( page )
320 });
321
322 // Create scroll triggers that show/hide fragments
323 this.createFragmentTriggersForPage( page );
324
325 // Create scroll triggers for triggering auto-animate steps
326 if( page.autoAnimateElements.length > 0 ) {
327 this.createAutoAnimateTriggersForPage( page );
328 }
329
330 let totalScrollTriggerCount = Math.max( page.scrollTriggers.length - 1, 0 );
331
332 // Each auto-animate step may include its own scroll triggers
333 // for fragments, ensure we count those as well
334 totalScrollTriggerCount += page.autoAnimatePages.reduce( ( total, page ) => {
335 return total + Math.max( page.scrollTriggers.length - 1, 0 );
336 }, page.autoAnimatePages.length );
337

Callers 1

layoutMethod · 0.95

Calls 13

createPageMethod · 0.95
activatePageMethod · 0.95
deactivatePageMethod · 0.95
setTriggerRangesMethod · 0.95
createProgressBarMethod · 0.95
syncProgressBarMethod · 0.95
removeProgressBarMethod · 0.95
getConfigMethod · 0.80
getComputedSlideSizeMethod · 0.80
getScaleMethod · 0.80

Tested by

no test coverage detected