• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trotzig / diffux / 205
98%
master: 99%

Build:
Build:
LAST BUILD BRANCH: animations
DEFAULT BRANCH: master
Ran 27 Feb 2014 05:19AM UTC
Jobs 2
Files 25
Run time –
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
205

push

travis-ci

trotzig
Only scroll when necessary on keyboard navigation

This commit replaces the previous usage of the native JS function
`scrollIntoView` with a jQuery solution instead. The new solution:

- Only scrolls when the focused element is hidden.
- Keeps 1/4 of the screen above the focused element (for context).
- Animates the scroll (this improved the experience by *a lot*, because
  you can see exactly what happens)

To figure out if an element is shown on the screen or not, I'm using the
`jquery.visible` Bower plugin. I tried out a couple of alternatives that
did scrolling, but both `jquery.scrollIntoView` (buggy) and
`jquery.scrollTo` (didn't avoid scrolling if it wasn't needed) came in
short.

An important detail about the animation: The previous animation is
cancelled (`stop()`ed) before the next is started. This is important in
order to allow people hammering/holding down j/k.

Why scroll both 'html' and 'body'? Well, 'body' works for Chrome, and
'html' works for Firefox. Even though we don't care much about browser
compatibility, I think Firefox users deserve to get scrolling
functionality. @ted27 will at least thank me (I hope).

434 of 445 relevant lines covered (97.53%)

52.48 hits per line

Jobs
ID Job ID Ran Files Coverage
1 205.1 (2.0.0) 27 Feb 2014 05:20AM UTC 0
97.53
Travis Job 205.1
2 205.2 (2.1.0) 27 Feb 2014 05:19AM UTC 0
97.53
Travis Job 205.2
Source Files on build 205
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #205
  • 2a5ef90a on github
  • Prev Build on better-nav-scroll (#203)
  • Next Build on better-nav-scroll (#206)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc