ng-scrollbar icon indicating copy to clipboard operation
ng-scrollbar copied to clipboard

Solution to get it worked when used inside a directive

Open lmauri opened this issue 10 years ago • 6 comments

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.

lmauri avatar Jul 03 '14 09:07 lmauri

Hi, have you try to rebuild the scrollbar whenever the content is changed ?

asafdav avatar Sep 29 '14 08:09 asafdav

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?

webspeaks avatar Dec 26 '14 10:12 webspeaks

@arvind07 take a look at this simple example - http://plnkr.co/45EoWm

paranoicsan avatar Dec 26 '14 12:12 paranoicsan

@paranoicsan Thanks :) It seems to work. Forked a new example - http://plnkr.co/edit/h6E7ViZQ9Yr7kbmuARHb Playing more with it.

webspeaks avatar Dec 26 '14 12:12 webspeaks

@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?

webspeaks avatar Dec 26 '14 13:12 webspeaks

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.

balaameex avatar Apr 28 '15 08:04 balaameex