Skip to content

Commit

Permalink
overview now works with percentage based width/height #1247
Browse files Browse the repository at this point in the history
hakimel committed Apr 13, 2016

Unverified

No user is associated with the committer email.
1 parent cb092e6 commit 5dd9067
Showing 3 changed files with 26 additions and 27 deletions.
5 changes: 3 additions & 2 deletions css/reveal.css
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ html, body, .reveal div, .reveal span, .reveal applet, .reveal object, .reveal i
.reveal article, .reveal aside, .reveal canvas, .reveal details, .reveal embed,
.reveal figure, .reveal figcaption, .reveal footer, .reveal header, .reveal hgroup,
.reveal menu, .reveal nav, .reveal output, .reveal ruby, .reveal section, .reveal summary,
.reveal time, .reveal mark, .reveal audio, video {
.reveal time, .reveal mark, .reveal audio, .reveal video {
margin: 0;
padding: 0;
border: 0;
@@ -989,7 +989,8 @@ html:-moz-full-screen-ancestor {
-webkit-perspective: 700px;
perspective: 700px; }
.reveal.overview .slides section {
height: 700px;
height: 100%;
top: 0 !important;
opacity: 1 !important;
overflow: hidden;
visibility: visible !important;
3 changes: 2 additions & 1 deletion css/reveal.scss
Original file line number Diff line number Diff line change
@@ -1022,7 +1022,8 @@ html:-moz-full-screen-ancestor {
perspective: 700px;

.slides section {
height: 700px;
height: 100%;
top: 0 !important;
opacity: 1 !important;
overflow: hidden;
visibility: visible !important;
45 changes: 21 additions & 24 deletions js/reveal.js
Original file line number Diff line number Diff line change
@@ -166,6 +166,10 @@
// Flags if the overview mode is currently active
overview = false,

// Holds the dimensions of our overview slides, including margins
overviewSlideWidth = null,
overviewSlideHeight = null,

// The horizontal and vertical index of the currently active slide
indexh,
indexv,
@@ -1798,6 +1802,17 @@
}
} );

// Calculate slide sizes
var margin = 70;
var slideSize = getComputedSlideSize();
overviewSlideWidth = slideSize.width + margin;
overviewSlideHeight = slideSize.height + margin;

// Reverse in RTL mode
if( config.rtl ) {
overviewSlideWidth = -overviewSlideWidth;
}

updateSlidesVisibility();
layoutOverview();
updateOverview();
@@ -1821,38 +1836,29 @@
*/
function layoutOverview() {

var margin = 70;
var slideWidth = config.width + margin,
slideHeight = config.height + margin;

// Reverse in RTL mode
if( config.rtl ) {
slideWidth = -slideWidth;
}

// Layout slides
toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
hslide.setAttribute( 'data-index-h', h );
transformElement( hslide, 'translate3d(' + ( h * slideWidth ) + 'px, 0, 0)' );
transformElement( hslide, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );

if( hslide.classList.contains( 'stack' ) ) {

toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
vslide.setAttribute( 'data-index-h', h );
vslide.setAttribute( 'data-index-v', v );

transformElement( vslide, 'translate3d(0, ' + ( v * slideHeight ) + 'px, 0)' );
transformElement( vslide, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
} );

}
} );

// Layout slide backgrounds
toArray( dom.background.childNodes ).forEach( function( hbackground, h ) {
transformElement( hbackground, 'translate3d(' + ( h * slideWidth ) + 'px, 0, 0)' );
transformElement( hbackground, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );

toArray( hbackground.querySelectorAll( '.slide-background' ) ).forEach( function( vbackground, v ) {
transformElement( vbackground, 'translate3d(0, ' + ( v * slideHeight ) + 'px, 0)' );
transformElement( vbackground, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
} );
} );

@@ -1864,19 +1870,10 @@
*/
function updateOverview() {

var margin = 70;
var slideWidth = config.width + margin,
slideHeight = config.height + margin;

// Reverse in RTL mode
if( config.rtl ) {
slideWidth = -slideWidth;
}

transformSlides( {
overview: [
'translateX('+ ( -indexh * slideWidth ) +'px)',
'translateY('+ ( -indexv * slideHeight ) +'px)',
'translateX('+ ( -indexh * overviewSlideWidth ) +'px)',
'translateY('+ ( -indexv * overviewSlideHeight ) +'px)',
'translateZ('+ ( window.innerWidth < 400 ? -1000 : -2500 ) +'px)'
].join( ' ' )
} );

0 comments on commit 5dd9067

Please sign in to comment.