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

Scroll-Area has wrong height, when around a div using ng-scrollbar a parent div is used #18

Open
stnswz opened this issue Aug 29, 2014 · 2 comments

Comments

@stnswz
Copy link

stnswz commented Aug 29, 2014

Hi, I really cant understand what the reason for this missbehave is, but its a very annoying bug and never should be the behave of a scrollbar. Just try simply using a DIV around the DIV that uses ng-scrollbar:

(style)
.parentDiv {
width:550px;
height:300px;
background-color:#444444;
}
.scrollDiv {
height: 250px;
width: 500px;
border-style:solid;
border-width:1px;
border-color: #ff0000;
background-color:#777777;
overflow:hidden;
}
(/style)

(div class="parentDiv")

(div class="scrollDiv" ng-scrollbar )
    (b)Scroll me down!(/b)(br)
    text(br) text(br) text(br) text(br) text(br) text(br) 
            text(br) text(br) text(br) text(br) .....
(/div)

(/div)

The result is that the scrolling area in scrollDiv is not 250 px height as you would expect, instead its only around the half. Remove the parent div and the scrolling area is ok. Expected is that the scrollbar has the same height as it is set for the scrollDiv, but its not when the parent div is around. It doesnt make any sense to me and really absolutely should not be the behave of a scrollbar. Why is that? And how to get around this?

@asafdav
Copy link
Owner

asafdav commented Sep 29, 2014

Hi, Can you please post a gist or plunker that I can play with ?

Thanks

@solenoo
Copy link

solenoo commented Mar 6, 2015

@stnswz I found out that the height is being calculated like this "page.height = element[0].offsetHeight - parentOffsetTop;". That's why the height of the scrolling area is not the same as the scrollDiv height, cause it removes the parentOffsetTop from those "250px" that you've set as height. What I did to fix this (not saying is the right way but it works for me) is I've set the page.height to be equal to the child height in other words I did this "page.height = element[0].firstChild.clientHeight;"

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

3 participants