correction to vertical centering and overview mode, clean up of vertical slide storage

This commit is contained in:
Hakim El Hattab 2012-11-10 15:28:34 -05:00
parent b4815a3a83
commit 891a66b5c4
3 changed files with 154 additions and 122 deletions

View File

@ -509,7 +509,6 @@ body {
width: 80%; width: 80%;
left: 50%; left: 50%;
top: 50%; top: 50%;
padding: 20px 0px;
overflow: visible; overflow: visible;
z-index: 1; z-index: 1;
@ -537,6 +536,7 @@ body {
display: none; display: none;
position: absolute; position: absolute;
width: 100%; width: 100%;
padding: 20px 0px;
z-index: 10; z-index: 10;
line-height: 1.2em; line-height: 1.2em;
@ -579,10 +579,10 @@ body {
.reveal.center, .reveal.center,
.reveal.center .slides { .reveal.center .slides {
min-height: auto; min-height: auto;
padding: 0;
} }
/********************************************* /*********************************************
* DEFAULT TRANSITION * DEFAULT TRANSITION
*********************************************/ *********************************************/
@ -1056,7 +1056,6 @@ body {
} }
.reveal.overview .slides section { .reveal.overview .slides section {
padding: 20px 0;
height: 600px; height: 600px;
overflow: hidden; overflow: hidden;
opacity: 1!important; opacity: 1!important;
@ -1078,13 +1077,12 @@ body {
.reveal.overview .slides section:hover { .reveal.overview .slides section:hover {
background: rgba(0,0,0,0.3); background: rgba(0,0,0,0.3);
} }
.reveal.overview .slides section.present { .reveal.overview .slides section.present {
background: rgba(0,0,0,0.3); background: rgba(0,0,0,0.3);
} }
.reveal.overview .slides>section.stack { .reveal.overview .slides>section.stack {
background: none;
padding: 0; padding: 0;
background: none;
overflow: visible; overflow: visible;
} }

View File

@ -1,5 +1,5 @@
/*! /*!
* reveal.js 2.2 r42 * reveal.js 2.2 r43
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
@ -519,6 +519,35 @@ var Reveal = (function(){
} }
/**
* Stores the vertical index of a stack so that the same
* vertical slide can be selected when navigating to and
* from the stack.
*
* @param {HTMLElement} stack The vertical stack element
* @param {int} v Index to memorize
*/
function setPreviousVerticalIndex( stack, v ) {
if( stack ) {
stack.setAttribute( 'data-previous-indexv', v || 0 );
}
}
/**
* Retrieves the vertical index which was stored using
* #setPreviousVerticalIndex() or 0 if no previous index
* exists.
*
* @param {HTMLElement} stack The vertical stack element
*/
function getPreviousVerticalIndex( stack ) {
if( stack && stack.classList.contains( 'stack' ) ) {
return parseInt( stack.getAttribute( 'data-previous-indexv' ) || 0 );
}
return 0;
}
/** /**
* Displays the overview of slides (quick nav) by * Displays the overview of slides (quick nav) by
* scaling down and arranging all slide elements. * scaling down and arranging all slide elements.
@ -547,32 +576,40 @@ var Reveal = (function(){
hslide.style.OTransform = htransform; hslide.style.OTransform = htransform;
hslide.style.transform = htransform; hslide.style.transform = htransform;
if( !hslide.classList.contains( 'stack' ) ) { if( hslide.classList.contains( 'stack' ) ) {
var verticalSlides = hslide.querySelectorAll( 'section' );
for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
var verticalIndex = i === indexh ? indexv : getPreviousVerticalIndex( hslide );
var vslide = verticalSlides[j],
vtransform = 'translate(0%, ' + ( ( j - verticalIndex ) * 105 ) + '%)';
vslide.setAttribute( 'data-index-h', i );
vslide.setAttribute( 'data-index-v', j );
vslide.style.display = 'block';
vslide.style.WebkitTransform = vtransform;
vslide.style.MozTransform = vtransform;
vslide.style.msTransform = vtransform;
vslide.style.OTransform = vtransform;
vslide.style.transform = vtransform;
// Navigate to this slide on click
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
}
}
else {
// Navigate to this slide on click // Navigate to this slide on click
hslide.addEventListener( 'click', onOverviewSlideClicked, true ); hslide.addEventListener( 'click', onOverviewSlideClicked, true );
} }
var verticalSlides = hslide.querySelectorAll( 'section' );
for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
var vslide = verticalSlides[j],
vtransform = 'translate(0%, ' + ( ( j - ( i === indexh ? indexv : 0 ) ) * 105 ) + '%)';
vslide.setAttribute( 'data-index-h', i );
vslide.setAttribute( 'data-index-v', j );
vslide.style.display = 'block';
vslide.style.WebkitTransform = vtransform;
vslide.style.MozTransform = vtransform;
vslide.style.msTransform = vtransform;
vslide.style.OTransform = vtransform;
vslide.style.transform = vtransform;
// Navigate to this slide on click
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
}
} }
layout();
} }
} }
@ -604,7 +641,7 @@ var Reveal = (function(){
element.removeEventListener( 'click', onOverviewSlideClicked ); element.removeEventListener( 'click', onOverviewSlideClicked );
} }
slide(); slide( indexh, indexv );
} }
} }
@ -706,14 +743,14 @@ var Reveal = (function(){
// If no vertical index is specified and the upcoming slide is a // If no vertical index is specified and the upcoming slide is a
// stack, resume at its previous vertical index // stack, resume at its previous vertical index
if( v === undefined && horizontalSlides[ h ] && horizontalSlides[ h ].classList.contains( 'stack' ) ) { if( v === undefined ) {
v = parseInt( horizontalSlides[ h ].getAttribute( 'data-previous-indexv' ) || 0 ); v = getPreviousVerticalIndex( horizontalSlides[ h ] );
} }
// If we were on a vertical stack, remember what vertical index // If we were on a vertical stack, remember what vertical index
// it was on so we can resume at the same position when returning // it was on so we can resume at the same position when returning
if( previousSlide && previousSlide.parentNode.classList.contains( 'stack' ) ) { if( previousSlide && previousSlide.parentNode.classList.contains( 'stack' ) ) {
previousSlide.parentNode.setAttribute( 'data-previous-indexv', indexv ); setPreviousVerticalIndex( previousSlide.parentNode, indexv );
} }
// Remember the state before this slide // Remember the state before this slide
@ -1442,10 +1479,7 @@ var Reveal = (function(){
deactivateOverview(); deactivateOverview();
indexh = this.getAttribute( 'data-index-h' ); slide( parseInt( this.getAttribute( 'data-index-h' ) ), parseInt( this.getAttribute( 'data-index-v' ) ) );
indexv = this.getAttribute( 'data-index-v' );
slide();
} }
} }

174
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long