@@ -345,36 +345,42 @@ window.QuartoSupport = function () {
345
345
}
346
346
}
347
347
348
- // FIXME: Possibly remove this wrapper when upstream trigger is fixed
348
+ // FIXME: Possibly remove this wrapper class when upstream trigger is fixed
349
349
// https://github.com/hakimel/reveal.js/issues/3688
350
350
// 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 ) ;
361
364
}
362
365
}
363
366
}
364
367
368
+ let scrollViewToggler ;
369
+
365
370
function installScollViewKeyBindings ( deck ) {
366
371
var config = deck . getConfig ( ) ;
367
372
var shortcut = config . scrollViewShortcut || 'R' ;
368
373
Reveal . addKeyBinding ( {
369
374
keyCode : shortcut . toUpperCase ( ) . charCodeAt ( 0 ) ,
370
375
key : shortcut . toUpperCase ( ) ,
371
376
description : 'Scroll View Mode'
372
- } , toggleScrollViewWrapper ( deck ) ) ;
377
+ } , ( ) => { scrollViewToggler . toggleScrollViewWrapper ( ) } ) ;
373
378
}
374
379
375
380
return {
376
381
id : "quarto-support" ,
377
382
init : function ( deck ) {
383
+ scrollViewToggler = new ScrollViewToggler ( deck ) ;
378
384
controlsAuto ( deck ) ;
379
385
previewLinksAuto ( deck ) ;
380
386
fixupForPrint ( deck ) ;
@@ -392,6 +398,8 @@ window.QuartoSupport = function () {
392
398
cleanEmptyAutoGeneratedContent ( deck ) ;
393
399
} ,
394
400
// Export for adding in menu
395
- toggleScrollView : toggleScrollViewWrapper ,
401
+ toggleScrollView : function ( ) {
402
+ scrollViewToggler . toggleScrollViewWrapper ( ) ;
403
+ }
396
404
} ;
397
405
} ;
0 commit comments