How to find the height of a dynamic element with angularjs?

5

I have a menu with accordion effect I need to find out how tall this menu is, remembering that the height is dynamic, ie when it has some open element it gets bigger.

Then you need to find the position of the clicked element relative to the scroll.

Basically what I'm trying to do is when I click on the item I recognize the height of the menu and its position on the scroll, then I go up the screen x% to center the clicked content.

Any help is welcome, thanks

    
asked by anonymous 04.02.2015 / 16:39

1 answer

1

Actually what you need is an angle component called $ anchorScroll .

  

When called, it scrolls to the specified element hash or (if omitted) to the current value of $ location.hash (), according to the rules specified in the HTML5 spec. (Google)

The annoying part of this component is that you can not use it in conjunction with ngAnimate to make animations.

If you want to do with a bit of animation, you can take a look at in this example StackOverFlow gringo, which is simple but expresses well what you want.

    
28.04.2015 / 21:38