Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggleScrollView() API does not allow to toggle scroll view if scrollActivationWidth is set #3688

Open
cderv opened this issue Oct 10, 2024 · 0 comments

Comments

@cderv
Copy link

cderv commented Oct 10, 2024

Using default configuration, we inherit Automatic Activation of scroll view on mobile.

reveal.js/js/config.js

Lines 285 to 287 in 669cc25

// Automatically activate the scroll view when we the viewport falls
// below the given width.
scrollActivationWidth: 435,

I was trying in this mode to a menu button (using menu pluggin) and a keyboard shortcut to trigger scroll mode using API Reveal.toggleScrollView()

However, it was not working and I checked that in browser console Reveal.toggleScrollView() does not apply.

I debugged step into the logic, and found that at some point in scrollView activate() Reveal.layout() will be called on the new document DOM

this.Reveal.layout();

which will check for scrollView responsive

checkResponsiveScrollView();

And it will call scrollView deactivate() as long as the scrollActivationWidth is set

reveal.js/js/reveal.js

Lines 1092 to 1120 in 669cc25

function checkResponsiveScrollView() {
// Only proceed if...
// 1. The DOM is ready
// 2. Layouts aren't disabled via config
// 3. We're not currently printing
// 4. There is a scrollActivationWidth set
// 5. The deck isn't configured to always use the scroll view
if(
dom.wrapper &&
!config.disableLayout &&
!printView.isActive() &&
typeof config.scrollActivationWidth === 'number' &&
config.view !== 'scroll'
) {
const size = getComputedSlideSize();
if( size.presentationWidth > 0 && size.presentationWidth <= config.scrollActivationWidth ) {
if( !scrollView.isActive() ) {
backgrounds.create();
scrollView.activate()
};
}
else {
if( scrollView.isActive() ) scrollView.deactivate();
}
}
}

Only when scrollActivationWidth is not a number then Reveal.toggleScrollView() will ignore the responsible and work. (like in https://revealjs.com/demo/ where Reveal.getConfig().scrollActivationWidth is null)

I would have expect Reveal.toggleScrollView() to not be impacted by the presentation size logic as it is an API call explicitly done by user or other tools like I am trying to do.

Hope this is clear enough. please to tell me if an example if needed to illustrate better the usage and problem encountered.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant