@@ -345,36 +345,42 @@ window.QuartoSupport = function () {
345345 }
346346 }
347347
348- // FIXME: Possibly remove this wrapper when upstream trigger is fixed
348+ // FIXME: Possibly remove this wrapper class when upstream trigger is fixed
349349 // https://github.com/hakimel/reveal.js/issues/3688
350350 // Currently, scrollActivationWidth needs to be unset for toggle to work
351- function toggleScrollViewWrapper ( deck ) {
352- let oldscrollActivationWidth ;
353- return ( ) => {
354- if ( deck . isScrollView ( ) === true ) {
355- deck . configure ( { scrollActivationWidth : oldscrollActivationWidth } ) ;
356- deck . toggleScrollView ( false ) ;
357- } else if ( deck . isScrollView ( ) === false ) {
358- oldscrollActivationWidth = deck . getConfig ( ) [ 'scrollActivationWidth' ] ;
359- deck . configure ( { scrollActivationWidth : null } ) ;
360- deck . toggleScrollView ( true ) ;
351+ class ScrollViewToggler {
352+ constructor ( deck ) {
353+ this . deck = deck ;
354+ this . oldScrollActivationWidth = deck . getConfig ( ) [ 'scrollActivationWidth' ] ;
355+ }
356+
357+ toggleScrollViewWrapper ( ) {
358+ if ( this . deck . isScrollView ( ) === true ) {
359+ this . deck . configure ( { scrollActivationWidth : this . oldScrollActivationWidth } ) ;
360+ this . deck . toggleScrollView ( false ) ;
361+ } else if ( this . deck . isScrollView ( ) === false ) {
362+ this . deck . configure ( { scrollActivationWidth : null } ) ;
363+ this . deck . toggleScrollView ( true ) ;
361364 }
362365 }
363366 }
364367
368+ let scrollViewToggler ;
369+
365370 function installScollViewKeyBindings ( deck ) {
366371 var config = deck . getConfig ( ) ;
367372 var shortcut = config . scrollViewShortcut || 'R' ;
368373 Reveal . addKeyBinding ( {
369374 keyCode : shortcut . toUpperCase ( ) . charCodeAt ( 0 ) ,
370375 key : shortcut . toUpperCase ( ) ,
371376 description : 'Scroll View Mode'
372- } , toggleScrollViewWrapper ( deck ) ) ;
377+ } , ( ) => { scrollViewToggler . toggleScrollViewWrapper ( ) } ) ;
373378 }
374379
375380 return {
376381 id : "quarto-support" ,
377382 init : function ( deck ) {
383+ scrollViewToggler = new ScrollViewToggler ( deck ) ;
378384 controlsAuto ( deck ) ;
379385 previewLinksAuto ( deck ) ;
380386 fixupForPrint ( deck ) ;
@@ -392,6 +398,8 @@ window.QuartoSupport = function () {
392398 cleanEmptyAutoGeneratedContent ( deck ) ;
393399 } ,
394400 // Export for adding in menu
395- toggleScrollView : toggleScrollViewWrapper ,
401+ toggleScrollView : function ( ) {
402+ scrollViewToggler . toggleScrollViewWrapper ( ) ;
403+ }
396404 } ;
397405} ;
0 commit comments