From 665dfb9cd63188a7c5a02aa1d3e2b593bf00bf2c Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 19 Dec 2018 09:38:15 +0100 Subject: [PATCH] add gridNavigation config to configure navigation between adjacent vertical stacks --- js/reveal.js | 22 ++++++++-- test/test-grid-navigation.html | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 test/test-grid-navigation.html diff --git a/js/reveal.js b/js/reveal.js index 4cf43f7c..16ff6df1 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -104,6 +104,20 @@ // Change the presentation direction to be RTL rtl: false, + // When this is enabled, stepping left/right from a vertical stack + // to an adjacent vertical stack will land you at the same vertical + // index. + // + // Consider a deck with six slides ordered in two stacks like this: + // 1.1 2.1 + // 1.2 2.2 + // 1.3 2.3 + // + // If you're on slide 1.3 and navigate right, you will normally move + // from 1.3 -> 2.1. With "grid" enabled the same navigation takes you + // from 1.3 -> 2.3. + gridNavigation: false, + // Randomizes the order of slides each time the presentation loads shuffle: false, @@ -4678,12 +4692,12 @@ // Reverse for RTL if( config.rtl ) { if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) { - slide( indexh + 1 ); + slide( indexh + 1, config.gridNavigation ? indexv : undefined ); } } // Normal navigation else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) { - slide( indexh - 1 ); + slide( indexh - 1, config.gridNavigation ? indexv : undefined ); } } @@ -4695,12 +4709,12 @@ // Reverse for RTL if( config.rtl ) { if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) { - slide( indexh - 1 ); + slide( indexh - 1, config.gridNavigation ? indexv : undefined ); } } // Normal navigation else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) { - slide( indexh + 1 ); + slide( indexh + 1, config.gridNavigation ? indexv : undefined ); } } diff --git a/test/test-grid-navigation.html b/test/test-grid-navigation.html new file mode 100644 index 00000000..2814ca32 --- /dev/null +++ b/test/test-grid-navigation.html @@ -0,0 +1,74 @@ + + + + + + + reveal.js - Test Grid + + + + + + + +
+
+ + + + + + + + + +