fix pdf bg layering, simplify code

edit
Hakim El Hattab 2016-04-28 17:07:26 +02:00
parent 5558103522
commit 9b11915c3a
2 changed files with 16 additions and 36 deletions

View File

@ -82,6 +82,12 @@ ul, ol, div, p {
perspective-origin: 50% 50%; perspective-origin: 50% 50%;
} }
.reveal .slides .pdf-page {
position: relative;
overflow: hidden;
z-index: 1;
}
.reveal .slides section { .reveal .slides section {
page-break-after: always !important; page-break-after: always !important;
@ -132,13 +138,7 @@ ul, ol, div, p {
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
z-index: -1; height: 100%;
}
/* All elements should be above the slide-background */
.reveal section>* {
position: relative;
z-index: 1;
} }
/* Display slide speaker notes when 'showNotes' is enabled */ /* Display slide speaker notes when 'showNotes' is enabled */

View File

@ -607,8 +607,7 @@
// Wrap the slide in a page element and hide its overflow // Wrap the slide in a page element and hide its overflow
// so that no page ever flows onto another // so that no page ever flows onto another
var page = document.createElement( 'div' ); var page = document.createElement( 'div' );
page.className = 'page'; page.className = 'pdf-page';
page.style.overflow = 'hidden';
page.style.height = ( pageHeight * numberOfPages ) + 'px'; page.style.height = ( pageHeight * numberOfPages ) + 'px';
slide.parentNode.insertBefore( page, slide ); slide.parentNode.insertBefore( page, slide );
page.appendChild( slide ); page.appendChild( slide );
@ -618,14 +617,8 @@
slide.style.top = top + 'px'; slide.style.top = top + 'px';
slide.style.width = slideWidth + 'px'; slide.style.width = slideWidth + 'px';
// TODO Backgrounds need to be multiplied when the slide if( slide.slideBackgroundElement ) {
// stretches over multiple pages page.insertBefore( slide.slideBackgroundElement, slide );
var background = slide.querySelector( '.slide-background' );
if( background ) {
background.style.width = pageWidth + 'px';
background.style.height = ( pageHeight * numberOfPages ) + 'px';
background.style.top = -top + 'px';
background.style.left = -left + 'px';
} }
// Inject notes if `showNotes` is enabled // Inject notes if `showNotes` is enabled
@ -653,7 +646,7 @@
numberElement.classList.add( 'slide-number' ); numberElement.classList.add( 'slide-number' );
numberElement.classList.add( 'slide-number-pdf' ); numberElement.classList.add( 'slide-number-pdf' );
numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV ); numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV );
background.appendChild( numberElement ); page.appendChild( numberElement );
} }
} }
@ -733,24 +726,12 @@
// Iterate over all horizontal slides // Iterate over all horizontal slides
toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( slideh ) { toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( slideh ) {
var backgroundStack; var backgroundStack = createBackground( slideh, dom.background );
if( printMode ) {
backgroundStack = createBackground( slideh, slideh );
}
else {
backgroundStack = createBackground( slideh, dom.background );
}
// Iterate over all vertical slides // Iterate over all vertical slides
toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) { toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) {
if( printMode ) {
createBackground( slidev, slidev );
}
else {
createBackground( slidev, backgroundStack ); createBackground( slidev, backgroundStack );
}
backgroundStack.classList.add( 'stack' ); backgroundStack.classList.add( 'stack' );
@ -846,6 +827,8 @@
slide.classList.remove( 'has-dark-background' ); slide.classList.remove( 'has-dark-background' );
slide.classList.remove( 'has-light-background' ); slide.classList.remove( 'has-light-background' );
slide.slideBackgroundElement = element;
// If this slide has a background color, add a class that // If this slide has a background color, add a class that
// signals if it is light or dark. If the slide has no background // signals if it is light or dark. If the slide has no background
// color, no class will be set // color, no class will be set
@ -3406,10 +3389,7 @@
if( isPrintingPDF() ) { if( isPrintingPDF() ) {
var slide = getSlide( x, y ); var slide = getSlide( x, y );
if( slide ) { if( slide ) {
var background = slide.querySelector( '.slide-background' ); return slide.slideBackgroundElement;
if( background && background.parentNode === slide ) {
return background;
}
} }
return undefined; return undefined;