Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/resources/formats/revealjs/plugins/menu/quarto-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ window.RevealMenuToolHandlers = {
PdfExport.togglePdfExport();
}),
toggleScrollView: revealMenuToolHandler(function() {
Reveal.getPlugin("quarto-support").toggleScrollView(Reveal)();
Reveal.getPlugin("quarto-support").toggleScrollView();
})
};
34 changes: 21 additions & 13 deletions src/resources/formats/revealjs/plugins/support/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,36 +345,42 @@ window.QuartoSupport = function () {
}
}

// FIXME: Possibly remove this wrapper when upstream trigger is fixed
// FIXME: Possibly remove this wrapper class when upstream trigger is fixed
// https://github.com/hakimel/reveal.js/issues/3688
// Currently, scrollActivationWidth needs to be unset for toggle to work
function toggleScrollViewWrapper(deck) {
let oldscrollActivationWidth;
return () => {
if (deck.isScrollView() === true) {
deck.configure({scrollActivationWidth: oldscrollActivationWidth});
deck.toggleScrollView(false);
} else if (deck.isScrollView() === false) {
oldscrollActivationWidth = deck.getConfig()['scrollActivationWidth'];
deck.configure({scrollActivationWidth: null});
deck.toggleScrollView(true);
class ScrollViewToggler {
constructor(deck) {
this.deck = deck;
this.oldScrollActivationWidth = deck.getConfig()['scrollActivationWidth'];
}

toggleScrollViewWrapper() {
if (this.deck.isScrollView() === true) {
this.deck.configure({ scrollActivationWidth: this.oldScrollActivationWidth });
this.deck.toggleScrollView(false);
} else if (this.deck.isScrollView() === false) {
this.deck.configure({ scrollActivationWidth: null });
this.deck.toggleScrollView(true);
}
}
}

let scrollViewToggler;

function installScollViewKeyBindings(deck) {
var config = deck.getConfig();
var shortcut = config.scrollViewShortcut || 'R';
Reveal.addKeyBinding({
keyCode: shortcut.toUpperCase().charCodeAt( 0 ),
key: shortcut.toUpperCase(),
description: 'Scroll View Mode'
}, toggleScrollViewWrapper(deck) );
}, () => { scrollViewToggler.toggleScrollViewWrapper() } );
}

return {
id: "quarto-support",
init: function (deck) {
scrollViewToggler = new ScrollViewToggler(deck);
controlsAuto(deck);
previewLinksAuto(deck);
fixupForPrint(deck);
Expand All @@ -392,6 +398,8 @@ window.QuartoSupport = function () {
cleanEmptyAutoGeneratedContent(deck);
},
// Export for adding in menu
toggleScrollView: toggleScrollViewWrapper,
toggleScrollView: function() {
scrollViewToggler.toggleScrollViewWrapper();
}
};
};
Loading