When the panel is open, I need it to move back to the ".panel-title" of the one that was just clicked. I know that I can create a directive for this, for example (I got it from this site ):
.directive( 'scrollTop', scrollTop ); function scrollTop() { return { restrict: 'A', link: link }; } function link( $scope, element ) { $scope.collapsing = false; $scope.$watch( function() { return $(element).find( '.panel-collapse' ).hasClass( 'collapsing' ); }, function( status ) { if ( $scope.collapsing && !status ) { if ( $(element).hasClass( 'panel-open' ) ) { $( 'html,body' ).animate({ scrollTop: $(element).offset().top - 20 }, 500 ); } } $scope.collapsing = status; } ); }
And in HTML I had to use:
<div uib-accordion-group is-open="status.openPanel" scroll-top></div>
But this does not seem to work. When you click on the second panel, it opens the first and second panel and never scrolls at the top when you open the third.
I just need to scroll back to the ".panel-title" panel on which the button was clicked. I think itβs pretty funny that it seems so hard to do when a lot of time for the contents of the panel can drag on for quite some time, and I think most people will want to scroll the top of the information when opening the panel.
I saw other posts here, but they don't seem to be related to AngularJS. I am using "ui-bootstrap-tpls-2.1.3"
EDIT - Here is a plunger you can play with if you want.
Any help is greatly appreciated.
source share