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

Using same ID for scroll container across different views breaks scrolling #220

Open
astynax777 opened this issue Jul 5, 2019 · 0 comments

Comments

@astynax777
Copy link

I'm using AngularJS with ngRoute and when I move from one view to another, I found that if the two consecutive views each have a scroll container with the same ID, the scrolling breaks.

<div layout="row" layout-align="space-between" du-scroll-container="scroll-container">
</div>
<md-content layout="column" flex id="scroll-container">
</md-content>

The workaround is easy - make sure that each of your scroll containers have unique IDs.

I determined this was the issue by stepping through this function:

proto.duScrollTo = function (left, top, duration, easing) {
    var aliasFn;
    if (angular.isElement(left)) {
        aliasFn = this.duScrollToElement;
    } else if (angular.isDefined(duration)) {
        aliasFn = this.duScrollToAnimated;
    }
    if (aliasFn) {
        return aliasFn.apply(this, arguments);
    }
    var el = unwrap(this);
    if (isDocument(el)) {
        return $window.scrollTo(left, top);
    }
    el.scrollLeft = left;
    el.scrollTop = top; // <-- this was not updating probably because el is referencing an object that's not likely on the DOM anymore
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant