Skip to content
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

Add support for "visibilityBased" option #89

Open
BarnT opened this issue Jun 14, 2018 · 1 comment
Open

Add support for "visibilityBased" option #89

BarnT opened this issue Jun 14, 2018 · 1 comment

Comments

@BarnT
Copy link

BarnT commented Jun 14, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request

Expected behavior

I would like to have a new option, called "ngx-scroll-to-visibility-based", or something like this.
By default it should be false. If it's set to true, scroll should happen only if not the entire target is visible already.
The condition to do the actual scroll is supposed to be something like this:


targetBottomPos < currentScrollTopPos || targetTopPos > currentScrollBottomPos || targetBottomPos > currentScrollBottomPos

What is the motivation / use case for changing the behavior?

Imagine an accordion-style hierarchical menu. The user clicks on a parent menu: this event closes up the previously opened submenu items and opens (slides down for example) the current parent menu's submenu items. At this point it can easily happen that the opened items get out of the view. In this case we want to scroll to the freshly opened menu items. On the other hand if the entire freshly opened submenu items are visible without scroll, we don't want the site to do any scroll.

@BarnT
Copy link
Author

BarnT commented Jun 14, 2018

I've just uploaded a basic jquery plugin implementation that supports this option: https://github.com/BarnT/jquery.scrollToChild/blob/master/jquery.scrollToChild.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant