'gridNavigation' and 'simpleNavigation' merged into 'navigationMode' setting #2307

This commit is contained in:
Hakim El Hattab 2019-01-23 09:58:10 +01:00
parent 4c3f778e6e
commit 51b1658a60
2 changed files with 28 additions and 17 deletions

View File

@ -108,14 +108,25 @@
// Change the presentation direction to be RTL // Change the presentation direction to be RTL
rtl: false, rtl: false,
// When this is enabled, stepping only with previous and next slide. // Changes the behavior of our navigation directions.
simpleNavigation: false, //
// "default"
// Left/right arrow keys step between horizontal slides, up/down
// arrow keys step between vertical slides. Space key steps through
// all slides (both horizontal and vertical).
//
// "linear"
// When this is enabled, the left/right arrow keys step through all
// slides (both horizontal and vertical) in a linear way. If the
// presentation has no vertical slides this setting is identical
// to "default".
//
// "grid"
// When this is enabled, stepping left/right from a vertical stack // When this is enabled, stepping left/right from a vertical stack
// to an adjacent vertical stack will land you at the same vertical // to an adjacent vertical stack will land you at the same vertical
// index. // index.
// //
// Consider a deck with six slides ordered in two stacks like this: // Consider a deck with six slides ordered in two vertical stacks:
// 1.1 2.1 // 1.1 2.1
// 1.2 2.2 // 1.2 2.2
// 1.3 2.3 // 1.3 2.3
@ -123,7 +134,7 @@
// If you're on slide 1.3 and navigate right, you will normally move // If you're on slide 1.3 and navigate right, you will normally move
// from 1.3 -> 2.1. With "gridNavigation" enabled the same navigation // from 1.3 -> 2.1. With "gridNavigation" enabled the same navigation
// takes you from 1.3 -> 2.3. // takes you from 1.3 -> 2.3.
gridNavigation: false, navigationMode: 'default',
// Randomizes the order of slides each time the presentation loads // Randomizes the order of slides each time the presentation loads
shuffle: false, shuffle: false,
@ -4718,12 +4729,12 @@
// Reverse for RTL // Reverse for RTL
if( config.rtl ) { if( config.rtl ) {
if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) { if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) {
slide( indexh + 1, config.gridNavigation ? indexv : undefined ); slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
} }
} }
// Normal navigation // Normal navigation
else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) { else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) {
slide( indexh - 1, config.gridNavigation ? indexv : undefined ); slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
} }
} }
@ -4735,12 +4746,12 @@
// Reverse for RTL // Reverse for RTL
if( config.rtl ) { if( config.rtl ) {
if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) { if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) {
slide( indexh - 1, config.gridNavigation ? indexv : undefined ); slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
} }
} }
// Normal navigation // Normal navigation
else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) { else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) {
slide( indexh + 1, config.gridNavigation ? indexv : undefined ); slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
} }
} }
@ -5024,7 +5035,7 @@
if( firstSlideShortcut ) { if( firstSlideShortcut ) {
slide( 0 ); slide( 0 );
} }
else if( !isOverview() && config.simpleNavigation ) { else if( !isOverview() && config.navigationMode === 'linear' ) {
navigatePrev(); navigatePrev();
} }
else { else {
@ -5036,7 +5047,7 @@
if( lastSlideShortcut ) { if( lastSlideShortcut ) {
slide( Number.MAX_VALUE ); slide( Number.MAX_VALUE );
} }
else if( !isOverview() && config.simpleNavigation ) { else if( !isOverview() && config.navigationMode === 'linear' ) {
navigateNext(); navigateNext();
} }
else { else {
@ -5045,20 +5056,20 @@
} }
// K, UP // K, UP
else if( keyCode === 75 || keyCode === 38 ) { else if( keyCode === 75 || keyCode === 38 ) {
if( !isOverview() && config.simpleNavigation ) { if( !isOverview() && config.navigationMode === 'linear' ) {
navigatePrev(); navigatePrev();
} }
else { else {
navigateUp() navigateUp();
} }
} }
// J, DOWN // J, DOWN
else if( keyCode === 74 || keyCode === 40 ) { else if( keyCode === 74 || keyCode === 40 ) {
if( !isOverview() && config.simpleNavigation ) { if( !isOverview() && config.navigationMode === 'linear' ) {
navigateNext() navigateNext();
} }
else { else {
navigateDown() navigateDown();
} }
} }
// HOME // HOME

View File

@ -55,7 +55,7 @@
}); });
QUnit.test( 'Enabled', function( assert ) { QUnit.test( 'Enabled', function( assert ) {
Reveal.configure({ gridNavigation: true }); Reveal.configure({ navigationMode: 'grid' });
Reveal.slide( 0, 0 ); Reveal.slide( 0, 0 );
Reveal.right(); Reveal.right();
Reveal.down(); Reveal.down();