Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to get it worked when used inside a directive #14

Open
lmauri opened this issue Jul 3, 2014 · 6 comments
Open

Solution to get it worked when used inside a directive #14

lmauri opened this issue Jul 3, 2014 · 6 comments

Comments

@lmauri
Copy link

lmauri commented Jul 3, 2014

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.

@asafdav
Copy link
Owner

asafdav commented Sep 29, 2014

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

@webspeaks
Copy link

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?

@paranoicsan
Copy link
Contributor

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

@webspeaks
Copy link

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

@webspeaks
Copy link

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

@balaameex
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants