Scroll to in angularjs

前端 未结 5 468
半阙折子戏
半阙折子戏 2021-01-31 09:04

I am trying to scroll to an element on the page after I \'show\' it. I.E. i have a very long list of users and I display them as a list. Each element has an edit icon you can

5条回答
  •  隐瞒了意图╮
    2021-01-31 09:23

    you posted a question about this on my blog as well in the comments.

    Without looking at all of your code, I can only guess at this, but I can tell you a few things that might help:

    1. you can't scroll to a hidden element.
    2. The actual scrolling is done by a $watch that is setup by $anchorScroll which is processed during the $digest.
    3. Whatever you're setting up to show/hide that form element is also being processed in a $watch at $digest.

    So it looks like to me that it's trying to process the scroll before it processes the value to show the form. To fix this I'd try either refactoring the code you're using to show the form, or wrapping your $anchorScroll call in a $timeout to ensure it's excuted after the show's watch.

    I hope that helps.

提交回复
热议问题