Merge pull request #3182 from chivongv/fix-pdf-page-numbering

fix: pdf page numbering for fragment group
This commit is contained in:
Hakim El Hattab 2022-04-04 15:25:25 +02:00 committed by GitHub
commit fca5b33530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

1
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

View File

@ -66,6 +66,7 @@ export default class Print {
const pages = []; const pages = [];
const pageContainer = slides[0].parentNode; const pageContainer = slides[0].parentNode;
let slideNumber = 1;
// Slide and slide background layout // Slide and slide background layout
slides.forEach( function( slide, index ) { slides.forEach( function( slide, index ) {
@ -148,11 +149,11 @@ export default class Print {
// Inject slide numbers if `slideNumbers` are enabled // Inject slide numbers if `slideNumbers` are enabled
if( doingSlideNumbers ) { if( doingSlideNumbers ) {
const slideNumber = index + 1;
const numberElement = document.createElement( 'div' ); const numberElement = document.createElement( 'div' );
numberElement.classList.add( 'slide-number' ); numberElement.classList.add( 'slide-number' );
numberElement.classList.add( 'slide-number-pdf' ); numberElement.classList.add( 'slide-number-pdf' );
numberElement.innerHTML = slideNumber; numberElement.innerHTML = slideNumber;
slideNumber++;
page.appendChild( numberElement ); page.appendChild( numberElement );
} }
@ -166,7 +167,7 @@ export default class Print {
let previousFragmentStep; let previousFragmentStep;
fragmentGroups.forEach( function( fragments ) { fragmentGroups.forEach( function( fragments, index ) {
// Remove 'current-fragment' from the previous group // Remove 'current-fragment' from the previous group
if( previousFragmentStep ) { if( previousFragmentStep ) {
@ -182,6 +183,9 @@ export default class Print {
// Create a separate page for the current fragment state // Create a separate page for the current fragment state
const clonedPage = page.cloneNode( true ); const clonedPage = page.cloneNode( true );
const numberElement = clonedPage.querySelector( '.slide-number-pdf' );
const fragmentNumber = index + 1;
numberElement.innerHTML = numberElement.innerHTML + "." + fragmentNumber;
pages.push( clonedPage ); pages.push( clonedPage );
previousFragmentStep = fragments; previousFragmentStep = fragments;