Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Scroll Bug. #9370

Closed
Serabass opened this issue Aug 22, 2016 · 0 comments · Fixed by #9458
Closed

Scroll Bug. #9370

Serabass opened this issue Aug 22, 2016 · 0 comments · Fixed by #9458
Assignees
Labels
has: Pull Request A PR has been created to address this issue P5: nice to have These issues will not be fixed without community contributions. resolution: fixed type: bug
Milestone

Comments

@Serabass
Copy link

Serabass commented Aug 22, 2016

When I trying to open the menu or something like it I have a problem with page scrolling. This bug gives me a pain for a long time.
Maybe this problem is already discovered by you but I want to write my observations all the same.
Ok. I checked the code with Chrome debugger and discovered following:
When the script trying to modify body's style it uses $mdUtils.scrollTop function.

This function has a line with small bug:
return scrollTop || Math.abs(element[0].getBoundingClientRect().top);
angular-material.js:1032 (version v1.1.0-rc.5)

scrollTop variable can be equal zero, that in this case it will be converted to boolean and then second expression will be evaluated. In my case the returned value was 60.
You can use strict equation with null and undefined instead.

I wrote this small directive for temporary fix this bug till Angular Material will be updated:

`

app.directive('fixScroll', function ($window) {
    return {
        restrict: 'A',
        link: function (scope, el, attrs) {
            angular.element($window).on('scroll', function () {
                if (document.body.scrollTop === 0) {
                    document.body.scrollTop = 1;
                }
            });
        }
    }
});

`

It simply prevents the scrolling to 0.

@ThomasBurleson ThomasBurleson added the P5: nice to have These issues will not be fixed without community contributions. label Aug 22, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.1 milestone Aug 22, 2016
devversion added a commit to devversion/material that referenced this issue Aug 30, 2016
* Properly determines the viewport top offset, without any consistency issues for the `scrollTop`.
* The `scrollTop` method had a wrong name when passing an element, because it resolved the client rects in relative to the viewport.
* Now it determines the viewport top offset from the window (instead of using the body element - this is deprecated)

Fixes angular#9370.
@devversion devversion added the has: Pull Request A PR has been created to address this issue label Aug 30, 2016
devversion added a commit to devversion/material that referenced this issue Sep 9, 2016
* Properly determines the viewport top offset, without any consistency issues for the `scrollTop`.
* The `scrollTop` method had a wrong name when passing an element, because it resolved the client rects in relative to the viewport.
* Now it determines the viewport top offset from the window (instead of using the body element - this is deprecated)

Fixes angular#9370.
@kara kara closed this as completed in #9458 Sep 9, 2016
kara pushed a commit that referenced this issue Sep 9, 2016
* Properly determines the viewport top offset, without any consistency issues for the `scrollTop`.
* The `scrollTop` method had a wrong name when passing an element, because it resolved the client rects in relative to the viewport.
* Now it determines the viewport top offset from the window (instead of using the body element - this is deprecated)

Fixes #9370.
Frank3K pushed a commit to Frank3K/material that referenced this issue Sep 11, 2016
* Properly determines the viewport top offset, without any consistency issues for the `scrollTop`.
* The `scrollTop` method had a wrong name when passing an element, because it resolved the client rects in relative to the viewport.
* Now it determines the viewport top offset from the window (instead of using the body element - this is deprecated)

Fixes angular#9370.
@Splaktar Splaktar modified the milestones: 1.1.1, 1.1.2 Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue P5: nice to have These issues will not be fixed without community contributions. resolution: fixed type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants