Skip to content

Issue 578 (keep legend scrollbar position after toggle) #584

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

Conversation

n-riesco
Copy link
Contributor

No description provided.

n-riesco added 2 commits May 30, 2016 18:19
* Only set the scrollbar position during first render.

* Only register the wheel and drag listeners during first render.

* If the scrollbar is to be shown, ensure only the expanded scrollbox is
  drawn.

Fixes plotly#578
@etpinard
Copy link
Contributor

In commit 8f05316, you mentioned

Only register the wheel and drag listeners during first render.

This can't be just on first render. Consider, this case:

// in the test dashboard console

Tabs.plotMock('legend_scroll');

// then
var gd = Tabs.getGraph();
Plotly.relayout(gd, 'showlegend', false);

// then 
Plotly.relayout(gd, 'showlegend', true);

leads to an un-scrollable legend.

So, I think you'll need to relax the on-first-render requirement to something like every time the legend group enter selection is non-empty.

@n-riesco
Copy link
Contributor Author

@etpinard OK, I'll fix that and add a test for it.

n-riesco added 2 commits June 1, 2016 20:48
* Tested that event listeners in a legend work after hiding and
  showing back the legend.
@n-riesco
Copy link
Contributor Author

n-riesco commented Jun 1, 2016

PR is ready for review again.

@etpinard
Copy link
Contributor

etpinard commented Jun 2, 2016

@n-riesco getting there, but looks like the scroll bar does not appear after a relayout call.

gifrecord_2016-06-02_111721

Scrolling works though and makes the scroll bar appear.

@n-riesco
Copy link
Contributor Author

n-riesco commented Jun 2, 2016

@etpinard Well, finally the penny dropped! And I understood that it makes more sense to use the legend enter selection as you suggested.

BTW, what did you use to create the gif?

@@ -122,7 +119,8 @@ module.exports = function draw(gd) {
.call(setupTraceToggle, gd);
});

if(gd.firstRender) {
var firstRender = legend.enter().size() !== 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

nicely done.

@etpinard
Copy link
Contributor

etpinard commented Jun 6, 2016

BTW, what did you use to create the gif?

I'm using this script. Not the cleanest solution. But it gets the job done.

@etpinard
Copy link
Contributor

etpinard commented Jun 6, 2016

Great PR. Thanks @n-riesco

@etpinard etpinard merged commit 19a3735 into plotly:master Jun 6, 2016
@john-soklaski
Copy link
Contributor

This works great. Thanks @n-riesco !

@n-riesco n-riesco deleted the issue-578-do-not-reset-scrollbar-position-after-toggle branch June 7, 2016 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants