update the parallax background when the window resizes #595

This commit is contained in:
Hakim El Hattab 2013-09-15 14:58:41 -04:00
parent 8399e828db
commit 36061b43ba
2 changed files with 6 additions and 7 deletions

View File

@ -1080,6 +1080,7 @@ var Reveal = (function(){
} }
updateProgress(); updateProgress();
updateParallax();
} }
@ -1890,9 +1891,8 @@ var Reveal = (function(){
// Animate parallax background // Animate parallax background
if( dom.wrapper.getAttribute( 'data-parallax-background' ) || config.parallaxBackgroundImage ) { if( dom.wrapper.getAttribute( 'data-parallax-background' ) || config.parallaxBackgroundImage ) {
var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ); var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
var currentHorizontalSlide = horizontalSlides[ indexh ], verticalSlides = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
var backgroundSize = dom.wrapper.style.backgroundSize.split( ' ' ), var backgroundSize = dom.wrapper.style.backgroundSize.split( ' ' ),
backgroundWidth, backgroundHeight; backgroundWidth, backgroundHeight;
@ -1905,13 +1905,12 @@ var Reveal = (function(){
backgroundHeight = parseInt( backgroundSize[1], 10 ); backgroundHeight = parseInt( backgroundSize[1], 10 );
} }
var slideWidth = dom.wrapper.offsetWidth; var slideWidth = dom.wrapper.offsetWidth;
var horizontalSlideCount = horizontalSlides.length; var horizontalSlideCount = horizontalSlides.length;
var horizontalOffset = -( backgroundWidth - slideWidth ) / ( horizontalSlideCount-1 ) * indexh; var horizontalOffset = -( backgroundWidth - slideWidth ) / ( horizontalSlideCount-1 ) * indexh;
var slideHeight = dom.wrapper.offsetHeight; var slideHeight = dom.wrapper.offsetHeight;
var verticalSlideCount = currentVerticalSlides.length; var verticalSlideCount = verticalSlides.length;
var verticalOffset = verticalSlideCount > 0 ? -( backgroundHeight - slideHeight ) / ( verticalSlideCount-1 ) * indexv : 0; var verticalOffset = verticalSlideCount > 0 ? -( backgroundHeight - slideHeight ) / ( verticalSlideCount-1 ) * indexv : 0;
dom.wrapper.style.backgroundPosition = horizontalOffset + 'px ' + verticalOffset + 'px'; dom.wrapper.style.backgroundPosition = horizontalOffset + 'px ' + verticalOffset + 'px';

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long