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

There can be a lot more scrolled than just the window element. #3

Closed
aFarkas opened this issue Jul 25, 2019 · 4 comments · Fixed by #11
Closed

There can be a lot more scrolled than just the window element. #3

aFarkas opened this issue Jul 25, 2019 · 4 comments · Fixed by #11
Assignees
Labels
enhancement New feature or request

Comments

@aFarkas
Copy link

aFarkas commented Jul 25, 2019

I implemented something in a very old project. Here is a snippet:

    var calcScrollableElements = function(){
            var parent = element.parentNode;
            while(parent){
                if(parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth){
                    scrollableElements.push([parent, parent.scrollTop, parent.scrollLeft]);
                }
                parent = parent.parentNode;
            }
            parent = document.scrollingElement;
            scrollableElements.push([parent, parent.scrollTop, parent.scrollLeft]);
        };

        var restoreScrollPosition = function(){
            var i;

            for(i = 0; i < scrollableElements.length; i++){
                scrollableElements[i][0].scrollTop = scrollableElements[i][1];
                scrollableElements[i][0].scrollLeft = scrollableElements[i][2];
            }
            scrollableElements = [];
        };
@calvellido
Copy link
Owner

Uhmmm, true, didn't really thought about it. This is nice, thanks!

I'm out now, and I won't be able to get the laptop to dig a bit deeper, but I'll be back into it on Monday.

Cheers!

@mmoss
Copy link

mmoss commented Jan 23, 2020

Curious if there's been any more work/traction on the element-level scroll polyfill?

@calvellido calvellido self-assigned this Feb 5, 2020
@calvellido
Copy link
Owner

Hi @mmoss, I couldn't work on it after all, but I'll try to have a look at it these days.

Thanks for your interest!

@calvellido
Copy link
Owner

Hi @aFarkas, I'm tackling this in #11. I'll try to do some additional testing before merging it, but it's looking promising. As that's totally based on your code, let me know if you would like to be credited any additional way.

Thanks.

@calvellido calvellido added the enhancement New feature or request label Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants