ng-scrollbar
ng-scrollbar copied to clipboard
Solution to get it worked when used inside a directive
I've tried to use ng-scollbar inside a directive that needs to dynamically adjusts the height of scrollable content on demand. And it does not works.
After a litte dig up in the code, I've seen that page.height is not calculated correctly in the buildScrollbar funcions: page.height = element[0].offsetHeight - parentOffsetTop;
To solve this issues I've added a scope variable height, read from attributes height: ... scope.height = attrs.height; buildScrollbar() ...
And changed the line above this way: page.height = (scope.height > 0) ? scope.height : (element[0].offsetHeight - parentOffsetTop);
So in the html I can set up the height of my scrollable area:
Hope this helps.
Hi, have you try to rebuild the scrollbar whenever the content is changed ?
Tried to put the ng-scrollbar in a directive. But id does not work. I called "rebuilt" it but no luck. Can you please help?
@arvind07 take a look at this simple example - http://plnkr.co/45EoWm
@paranoicsan Thanks :) It seems to work. Forked a new example - http://plnkr.co/edit/h6E7ViZQ9Yr7kbmuARHb Playing more with it.
@paranoicsan I got the problem now. It fails in the case where the height of "div" is not specified in advance. See this plunker- http://plnkr.co/edit/h6E7ViZQ9Yr7kbmuARHb Is there any solution for this?
I tried to implement with ng-repeat it is not working. it is working only with static content. Help me to implemnt with dynamic content with ng-repeat.