Skip to content

Commit

Permalink
add possibility to export progress bar with URL option
Browse files Browse the repository at this point in the history
  • Loading branch information
frodew authored and astefanutti committed May 28, 2024
1 parent 6735cec commit 83771f9
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions plugins/reveal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import URI from 'urijs';

export const create = page => new Reveal(page);
export const options = {
fragments: {
default : false,
help : 'Enable or disable fragments',
},
progress: {
default : false,
help : 'Enable or disable progress bar',
},
};

export const create = (page, opts) => new Reveal(page, opts);

class Reveal {

constructor(page) {
constructor(page, opts) {
this.page = page;
this.options = opts;
this.fragments = this.options.fragments;
this.progress = this.options.progress;
}

getName() {
Expand All @@ -30,11 +44,11 @@ class Reveal {
}

configure() {
return this.page.evaluate(fragments => {
return this.page.evaluate(config => {
Reveal.configure({
controls : false,
progress : false,
fragments : fragments,
progress : config.progress,
fragments : config.fragments,
transition: 'none'
});

Expand All @@ -45,10 +59,10 @@ class Reveal {
menuOpenButtons[i].style.display = 'none';
}
},
// It seems passing 'fragments=true' in the URL query string does not take precedence
// over globally configured 'fragments' and prevents from being able to toggle fragments
// with ...?fragments=<true|false> so we work around that by parsing the page query string
(URI(this.page.url()).query(true)['fragments'] || 'false').toLowerCase() === 'true');
{
fragments: this.fragments,
progress: this.progress
});
}

slideCount() {
Expand Down

0 comments on commit 83771f9

Please sign in to comment.