-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Adjust for Scrollspy offset when calculating maxScroll. #13589
Adjust for Scrollspy offset when calculating maxScroll. #13589
Conversation
Is it feasible to add a unit test for this? |
I will attempt this. Not terribly familiar with Node and grunt, but I'll give it a shot! |
You can run the test suite ( |
I got it figured out. Thanks. I added a new test for the maxScroll and also fixed the one above it. I found that the Scrollspy process event handler was not being called until after the test had completed. The 'should only switch active class on current target' test was testing the active state did not change, which would have been always true since the process event handler had not executed yet. |
Does everything look good here now? Will this get merged? |
All signs are positive. Still need @fat to review this though. |
Thanks for the update. |
lgtm |
thank you very much! |
Running Sauce tests: https://travis-ci.org/twbs/bootstrap/jobs/25907931 |
Sauce tests passed. Merging per @fat's LGTM. |
Adjust for Scrollspy offset when calculating maxScroll.
There is a bug in Scrollspy where it will prematurely jump to the last navigation element when using an offset. The larger the offset used, the more prominent the problem becomes.
Here is a JSFiddle that shows the issue:
http://jsfiddle.net/4gnGy/4/
The fix is to add the offset to the maxScroll. All of the offsets created during Scrollspy initialization will be the offset + each element's scrollTop value so maxScroll needs to account for the offset as well.