-
Notifications
You must be signed in to change notification settings - Fork 368
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
If element is longer than viewport returns false. #37
Comments
Got the same problem over here. If the top or bottom of the element isn't in the window, even if there is a ton of content from the element in the window, it returns false. Any ideas? |
Isn't that what the first optional parameter is for? If you pass it 'true', it will return true if any part of the given element is visible. From the readme, and website:
Is that not working? I just tested, it seems to work for me. |
I've updated to 1.2.0 today and after a bit of testing, I can confirm the issue: if the top border of the target div (may it be the div itself, or just its padding) touches to top border of the viewport, then .visible() evaluates to false even if .visible(true) is specified! Using margin is fine, instead. However, in my situation I can't switch. Moreover, as soon as the bottom border of the div falls within the viewport, then .visible(true) evaluates again as True. Another strange behaviour is that .visible(true,false,'horizontal') always evaluates to True. (I made some testing as I'm building a WordPress theme using jquery-visible to check for visibility) Edit: it's a well known old issue... is it possible to check if the code works when applied to 1.2.0, as I'm loading it via CDNJS? |
Using the optional first parameter still acts as though the element isn't visible even when it is taking up the entire screen and just its top and bottom edges aren't visible.
It does not see the middle as "ANY PART", it only checks the corners, so if they aren't visible it returns false. When the content is long enough that it needs scrolling, it does not work as desired. Since time was a factor, I scrapped this plugin and used something different (https://github.com/moagrius/isOnScreen). Thank you though to the developers of this plugin because it's still pretty nice. |
I've just tried the code posted on #16 but it doesn't solve the issue @jayharland |
This has been idle for a long while but in case anyone cares, you can resolve this issue with adding the following line of code...
right after line 35. This statement just checks to see if the element top border is above the window top AND the bottom border is below the fold. |
@smcmillen Thanks, this works like charm, should be added in the repo itself. |
Resolved in latest commit. |
As described, if element being checked is longer than the window browser, it returns false when top and bottom of element are not visible.
The text was updated successfully, but these errors were encountered: