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

Keep scrolling position after editing #335

Open
CSharpSeraph opened this issue Feb 3, 2021 · 4 comments
Open

Keep scrolling position after editing #335

CSharpSeraph opened this issue Feb 3, 2021 · 4 comments

Comments

@CSharpSeraph
Copy link

Hi,

great work guys, I'm using it for very big charts that take lots of space both vertical and horizontal. I made the date cells editable so the user can edit the durations live. The problem is that after editing a value, e.g. very low in the scroll top position, the chart gets rendered again and it pulls back the user to x:0 y:0. Is there a "clean" way to keep the scroll position after changing values?

thanks a lot!

@mariohmol
Copy link
Collaborator

Well, is possible to add a listener to keep saving the last x,y position.. and then when the render methods runs again, set this 2 values again on the scroll

@CSharpSeraph
Copy link
Author

Hi! Yes, I tweaked the .js that way and it works just fine!

@mariohmol
Copy link
Collaborator

Awesome!! could u please share with us?

@mariohmol mariohmol reopened this Mar 1, 2021
@CSharpSeraph
Copy link
Author

CSharpSeraph commented Mar 3, 2021

Yup!

on

this.Draw = function () {

I have declared the variables:

    var CUR_SCROLL_TOP = 0; 
    var CUR_SCROLL_LEFT = 0;

after declaring the name of the very first container, but BEFORE creating it:

var newId = '#' + this.vDivId + 'gchartbody';

as first thing I save the positions. Please note that the very first time they won't be recorded because the main div does not exist yet, but after the first render I'll have an exising instance of the div to record the position, before the function destroys it and builds it again:

CUR_SCROLL_TOP = $(newId).scrollTop();
CUR_SCROLL_LEFT = $(newId).scrollLeft();

then at the very end, after :

this.drawComplete(vMinDate, vColWidth, bd);

I set the previous positions:

    if (CUR_SCROLL_TOP > 0) {
    
        $(newId).scrollTop(CUR_SCROLL_TOP);
    }
    if (CUR_SCROLL_LEFT > 0) {
    
$(newId).scrollLeft(CUR_SCROLL_LEFT);
    }

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

2 participants