Skip to content

#2371: Not disabling scrollZoom when page (plot) has scroll bar #3085

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

Closed
wants to merge 1 commit into from

Conversation

marfoldi
Copy link
Contributor

@marfoldi marfoldi commented Oct 9, 2018

Used to disable scrollzoom when the plot had scrollbars. Ended up with a plot which is not zoomable with mouse scroll on a page which had additional content (had a scrollbar).

Used to disable scrollzoom when the plot had scrollbars. Ended up with a plot which is not zoomable with mouse scroll on a page which had additional content (had a scrollbar).
@etpinard
Copy link
Contributor

etpinard commented Oct 9, 2018

Thanks for the PR!

I'm a little confused with some of the reports in #2371. Would you sharing an example of the situation you're trying to solve?

@marfoldi
Copy link
Contributor Author

marfoldi commented Oct 9, 2018

Sure. The scrollToZoom/PinchToZoom is not working (tested on Windows and on Android) when the page is scrollable (the piece of code which I just removed disables it). You can mimic the behavior by opening e.g. the following page: https://codepen.io/plotly/pen/QjKZbg and after the plot is loaded you resize your window. Also when I've opened the issue I've linked an example (http://marfoldi.web.elte.hu/plotly) which contains multiple plots (if you have a kinda regular resolution there should be a scrollbar on page) and none of the plots are zoomable by scrolling (however all of them has the scrollZoom: true property).

@etpinard
Copy link
Contributor

Thanks again for the PR and let me apologize for the delayed response (our 1.42.0 release cycle was a little hectic).

I think I agree that from a pure plotly.js standpoint your patch does indeed fix a bug. As scrollZoom is false by default, we should honor scrollZoom:true no matter what. Now unfortunately, the code you're 🔪 is ancient: there might some apps in the wild that depend on this extra "scroll-or-not-to-scroll" logic.

So, I'll suggest making the scollZoom config option accept another value. I'm thinking scrollZoom: 'always' would always activate scroll and scrollZoom: true would behave the same as currently.

@@ -434,13 +434,6 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {

recomputeAxisLists();

// if the plot has scrollbars (more than a tiny excess)
// disable scrollzoom too.
if(pc.scrollHeight - pc.clientHeight > 10 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. But the comment says if the *plot had scrollbars, not if the page has some.

Maybe we aren't using the correct DOM properties.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in https://codepen.io/plotly/pen/QjKZbg,

on full-screen I got:

image

but after resize to half-screen-width, I get e.g.

image


So perhaps we should compare pc.scrollWidth with fullLayout.width and pc.scrollHeight with fullLayout.height to determine if scroll should be activated.

@etpinard
Copy link
Contributor

etpinard commented Jan 9, 2019

Now in #3424 - thanks again @marfoldi !

@etpinard etpinard closed this Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants