-
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
Support check if is visible inside of a an element with overflow: scroll #11
Comments
This is a little utility plugin — Checking overflow/scroll position of all elements (where you'd possibly need to consider multiple nested scrolling elements) will probably bloat this plugin too much to be broadly useful. This might be the domain of a separate plugin? |
You may be interested in this though — it might solve your particular problem? https://github.com/tlaverdure/jquery-visible/commit/48c4c8dcc4a6dce2a02bfe11c5007d1adea14b01 |
That makes perfect sense, the problem is one of naming though. A decent percentage of people coming to this plugin would be looking for precisely the more complex behavior. As much as it would be nice to change the name that's of course not pragmatic (and a bit insulting to your project), it would help save those people time however if there was a big bold warning on the main page as to what this plugin can and cannot do (perhaps with a suggestion as to alternatives). |
I've added a note to that effect on the Readme under Limitations. One option would be to give the ability to define which viewport is used when running the check, allowing you to specify the element to target. We could then recursively call the plugin on it's parents to check for visibility — that would allow us to provide this functionality without adding too much code bulk. |
@samatdf I think that would be a great addition. Most of the time when your wanting to check on an element visibility, you know that it's in a container that has overflow: scroll and you want to check visibility against that container. |
Cool, if there are some people interested in this I'll definitely take a look. |
👍 Currently encountering this exact problem. I think the nested overflow: scroll would be insane to solve, but something like specifying a single scrolling container within which the element resides would be awesome. |
Take a look at http://api.jqueryui.com/scrollParent/ |
So far, I haven't found a way to check if an element is visible inside a div with "overflow: scroll". Every solution just check if the element is visible inside the viewport. If there could be some way to add that functionality, that would be awesome. |
👍 |
To see if an element is visible in nested scrolled containers, get the client rect for the element and its chain of parents. Filter out those parents for which don't have one of Gimme a minute, and I'll write a quick function around that. |
|
I am getting this error when i use that function @Fordi `
` |
That's weird? |
Currently this only checks visibility on the window object.
Paradoxically, if it is inside a div with
overflow: scroll
it will report "true" even if the element is not on the page.This is really anti-intuitive, jquery-visible really should check scroll visibility as well
The text was updated successfully, but these errors were encountered: