From 2dd3fbd1609a6e36faf9b148bc5fcf0165c2ad99 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Tue, 27 Sep 2016 21:49:44 +0200 Subject: [PATCH] Avoid race condition in RISE plugin configuration --- plugins/rise.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/plugins/rise.js b/plugins/rise.js index 15940bc..6db88e1 100644 --- a/plugins/rise.js +++ b/plugins/rise.js @@ -15,15 +15,23 @@ RISE.prototype = { }, configure: function () { - return new Promise(function (resolve) { - // Click on the Enter/Exit Live Reveal Slideshow button in the notebook toolbar - this.page.evaluate(function () { - $('#start_livereveal').click(); - $('#help_b,#exit_b').fadeToggle(); - }); - // Then wait a while and configure Reveal.js - setTimeout(function () { + return Promise.resolve() + // Wait a while until the RISE extension has loaded + // It'd be better to rely on a deterministic condition though the Jupyter JS API + // isn't stable and documented yet... + .then(delay(2000)) + // Click on the 'Enter/Exit Live Reveal Slideshow' button in the notebook toolbar + .then(function () { this.page.evaluate(function () { + $('#start_livereveal').click(); + $('#help_b, #exit_b').fadeToggle(); + }); + }) + // Then wait a bit until Reveal.js gets configured by the RISE extension + .then(delay(2000)) + // Finally override Reveal.js configuration + .then(function() { + page.evaluate(function () { Reveal.configure({ controls: false, progress: false, @@ -32,9 +40,7 @@ RISE.prototype = { fragments: false }); }); - resolve(); - }, 2000); - }); + }); }, slideCount: function () {