merge parallax into dev, remove default image #595

This commit is contained in:
Hakim El Hattab
2013-09-15 14:44:45 -04:00
8 changed files with 116 additions and 5 deletions

View File

@ -91,6 +91,12 @@ var Reveal = (function(){
// Transition style for full page slide backgrounds
backgroundTransition: 'default', // default/linear/none
// Parallax background image
parallaxBackgroundImage: '', // CSS syntax, e.g. "url('a.jpg')"
// Parallax background size
parallaxBackgroundSize: '', // CSS syntax, e.g. "3000px 2000px"
// Number of slides away from the current that are visible
viewDistance: 3,
@ -469,6 +475,25 @@ var Reveal = (function(){
} );
} );
// Add parallax background if specified so
var parallaxBackgroundImage = config.parallaxBackgroundImage,
parallaxBackgroundSize = config.parallaxBackgroundSize;
if (parallaxBackgroundImage) {
dom.wrapper.style.background = parallaxBackgroundImage;
dom.wrapper.style.backgroundSize = parallaxBackgroundSize;
// Make sure the below properties are set on the element - these properties are
// needed for proper transitions to be set on the element via CSS. To remove
// annoying background slide-in effect when the presentation starts, apply
// these properties after short time delay
setTimeout( function() {
dom.wrapper.setAttribute('data-parallax-background', parallaxBackgroundImage);
dom.wrapper.setAttribute('data-parallax-background-size', parallaxBackgroundSize);
}, 1 );
}
}
@ -1470,8 +1495,32 @@ var Reveal = (function(){
// Store references to the previous and current slides
currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
// Animate parallax background
if (dom.wrapper.getAttribute('data-parallax-background') || config.parallaxBackgroundImage) {
var bs = dom.wrapper.style.backgroundSize.split(' '),
bgWidth, bgHeight;
if (bs.length === 1) {
bgWidth = bgHeight = parseInt(bs[0], 10);
} else {
bgWidth = parseInt(bs[0], 10);
bgHeight = parseInt(bs[1], 10);
}
var slideWidth = parseInt(dom.wrapper.offsetWidth, 10);
var horizontalSlideCount = horizontalSlides.length;
var horizontalOffset = -(bgWidth - slideWidth)/(horizontalSlideCount-1) * h;
var slideHeight = parseInt(dom.wrapper.offsetHeight, 10);
var verticalSlideCount = currentVerticalSlides.length;
var verticalOffset = verticalSlideCount > 0 ? -(bgHeight - slideHeight)/(verticalSlideCount-1) * v : 0;
dom.wrapper.style.backgroundPosition = horizontalOffset + 'px ' + verticalOffset + 'px';
}
////////////////////////////////////
// Show fragment, if specified
if( typeof f !== 'undefined' ) {
var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) );

4
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long