thenikso / angular-inview

AngularJS directive to check if a DOM element is in the browser viewport.
http://thenikso.github.io/angular-inview/
MIT License
480 stars 112 forks source link

$inView is always false when top and bottom offsets overlap (element has no 'virtual height') #83

Closed Ben-Wormald closed 8 years ago

Ben-Wormald commented 8 years ago

I'm trying to get an element to only show when it's in a relatively small area in the middle of the window, so I've added a negative offsetBottom and positive offsetTop to set the bounds of where the element should be visible. However, when these offset values sum to more than the height of the element, it has no 'virtual height' and $inView always gives a value of false. This also occurs when using only either a negative offsetBottom or positive offsetTop greater than the element's height.

Would it be possible to allow $inView to be true when the element has a zero/negative virtual height?

(Or am I just using the offset values incorrectly?)

thenikso commented 8 years ago

In the current release it is not possible to offset the viewport dimensions, just the virtual dimensions of the actual element. I wouldn't know how to do what you are looking for with the current capabilities.

thenikso commented 8 years ago

now possible in v2