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
Target scrolling within a div #39
Comments
This should be possible. I'll look into it this week |
This would be a great feature. If possible you could pass a target option like: |
Am i right in understanding what you want from this is when you scroll a container with |
Yes. So, imagine someone creates a mobile site with that looks like this: http://jsfiddle.net/nicooprat/Aahqh/ Notice that the nav menu is fixed, the content scrolls, and there are slide out menus on either side. Ideally, your script should be able to target that fixed nav and hide it when someone scrolls the content. It can be a common convention for mobile sites to have fixed navs and scrolling content with slide menus. |
+1 for this feature. A scroll target is very necessary for mobile sites... |
You only need to add a new option parameter to your function, called, for example "target". Then if this parameter is omitted Headroom should use window as target (and as it's doing now) but if target element is specified then it should use scrollTop to get the scroll from that DOM item. The viewport height is the client height of that elem. just imagine a div with same window width an almost same height but with a top offset of N pixels. This is very frequent in mobile webapps. It should not be very difficult to make necessary changes to add this new feature into Headroom if you want and have some minutes for the task |
has this been added ? :) |
Can't wait :) |
This has now been added with #98 |
Is this not documented? |
If this is in fact still a supported feature please include it in the readme |
It's documented on the project site. The readme is out of sync it seems. In the near future I will likely make the website the canonical source of documentation for the lib, so use that as source of truth for now |
Sounds good. Tried out the featured. Works well. Like the API a lot |
Good to hear! |
I cannot get this feature to work, it throws an error; https://codepen.io/omikron/pen/BQKaRM
|
@omikron you must pass the actual element, not a selector, as the scroller option |
Sorry, not sure what you mean. Any chance you could modify the codepen to reflect that? |
Realized my implementation with jQuery was having an issue with passing the element as a jQuery object, but moving over to pure JS it worked fine. |
Many mobile websites have Facebook-style slidein menus and the main content div slides over to make room for those menusIn that case, the window doesn't scroll, but the main content div has a height of 100% and the content scrolls within that relatively or absolutely positioned div. (see snap.js as an example).
Is there a way to target the scrolling within a main div, rather than the window itself?
The text was updated successfully, but these errors were encountered: