-
Notifications
You must be signed in to change notification settings - Fork 23
It doesn't show up as visible if height is 0 #16
Comments
Hi, thanks for the bug report! Can you create a new failing test and submit a PR with a fix if needed? Everything needed is available in the repo to do so. Let me know. |
Thank you for reporting this bug. I was looking for what was happening :D |
Yes if an element has no height, it is not visible. Here is the line that is responsible of this feature : https://github.com/vvo/in-viewport/blob/master/in-viewport.js#L143 is it a problem? Cheers, |
For exemple, I have a list of blog post. I need to load social shares
(facebook count, Google plus count...) on each post. So I want to load my
components when blog post is in the viewport. Before loaded, wrapper are
empty so height is 0
|
Thanks for the details! This lib is made to detect "when an element becomes visible in a viewport". Perhaps we should simplify and detect only when an element is in a viewport, because this lib is uses for lazy loading most of the time. It would be simpler et prevent some issues with developers. Do you agree @vvo? |
I am not sure to get the distinction and your proposal. For sure I don't mind doing breaking changes but can you detail a bit more what do you mean? |
As @tzi mentioned, it could prevent common development issues since elements which are tested for the viewport presence are usually ones which should be lazy loaded and their placeholders usually don’t have any content, therefore, height with 0px. Maybe this could also be an option? Or just cater to that common use case by default without any option? |
@vvo what if the detection of 0px heighted elements was implementad as a method option? |
This prompted me to copy the visibility function, remove some of the functions I didn't need, and comment out these lines: Lines 153 to 155 in 04b22a6
Works dandily. |
I agree with @TehShrike solution, it would return a |
I am down for changing the behavior of the library, send a PR and we will discuss it! |
I think the confusion came from the fact that the library is named "in-viewport", but it internally uses a function named "isVisible". Those two things aren't always the same. |
I would appreciate if this behaviour could be passed in an |
It should show an element as visible independently of its height, but instead, it doesn't.
PoC
The text was updated successfully, but these errors were encountered: