jQuery scrollTop() returns 0 for all elements

后端 未结 3 1275
离开以前
离开以前 2020-12-31 09:46

At my job we have a one page site I created with AngularJS.
We\'re using the ui-router plugin (version 0.2.0).
Recently I\'ve noticed that when moving from one state

3条回答
  •  心在旅途
    2020-12-31 10:13

    As @Hans commented, there wasn't actually a problem. I had a wrapping element, that was positioned absolute with:

    top:0;
    bottom:0;
    left:0;
    right:0;
    overflow:auto
    

    So The window's scrollTop was always 0, and the scrollbar actually belonged to the wrapping element.

    Since I could't get rid of the wrapping element's positioning, I used ui-router's $stateChangeSuccess event, and manually scrolled the wrapping element to the top.

提交回复
热议问题