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

Provide window resize event #11602

Open
ghomem opened this issue Sep 14, 2021 · 3 comments
Open

Provide window resize event #11602

ghomem opened this issue Sep 14, 2021 · 3 comments

Comments

@ghomem
Copy link

ghomem commented Sep 14, 2021

Is your feature request related to a problem? Please describe.
In order to provide a python based reflow we need a window size event that can be hooked to a callback the manipulates the layouts (example horizontal versus vertical).

This has been discussed here:
https://discourse.bokeh.org/t/responsive-layout-with-reflow-for-screen-rotations/8219/23

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
For the sake of concern separation we would like to keep the layout logic on Bokeh and allow the switch between horizontal and vertical modes directly on the python code.

Describe the solution you'd like
A Bokeh WindowResized event that can be connected to a python callback.

Describe alternatives you've considered
The alternative is inserting individual plots - rather than grid - into the HTML, forcing the user to understand the complexities of HTML reflows.

Additional context
Add any other context or screenshots about the feature request here.

This vertical layout, from an otherwise horizontal website, has been achieved thanks to the DocumentReady event. With a WindowResized event we would achieve complete responsiveness.

Screenshot_20210914_015340

More information here:

https://discourse.bokeh.org/t/responsive-layout-with-reflow-for-screen-rotations/8219/23

@ghomem ghomem added the TRIAGE label Sep 14, 2021
@philippjfr
Copy link
Contributor

Having played around with this idea in the past I have to give a word of warnings. A lot of resize events are fired when resizing the browser window with a drag so without some kind of basic throttling/debouncing this will result in a poor UX. It's probably better to start thinking about having some responsive layout in Bokeh such as the FlexBox layout I implemented for Panel.

@ghomem
Copy link
Author

ghomem commented Sep 14, 2021

A lot of resize events are fired when resizing the browser window with a drag so without some kind of basic >throttling/debouncing this will result in a poor UX.

I already have code for not doing anything unless a specific relation between width and height is hit (i.e. throttling). So 99.99% of the time it would be a callback invocation without any impact. Still, it would create quite some client server communication.

Regardless, is it possible to have an event WindowResized event which is only triggered when the user stopped resizing?

I am not sure about FlexBox as I am not trying to achieve a continuous reflow, but rather a reflow that only happens on certain condition:

https://discourse.bokeh.org/t/responsive-layout-with-reflow-for-screen-rotations/8219/17?u=ghomem

@tcmetzger tcmetzger added python Issues that should only require updating Python code tag: component: bokehjs tag: component: server type: feature and removed TRIAGE labels Sep 14, 2021
@tcmetzger
Copy link
Member

As @bryevdv pointed out on Discourse (https://discourse.bokeh.org/t/responsive-layout-with-reflow-for-screen-rotations/8219/24), adding a window resize event that triggers when a resize operation has finished seems like a helpful, self-contained feature. The broader topic of accessing window size from Python is discussed here: #11471. bokehjs/src/lib/core/ui_events.ts might be a good starting point.

cc @bokeh/dev

@mattpap mattpap removed the python Issues that should only require updating Python code label Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants