Improve the styling and performance of diff expansion in reviews.

Review Request #9057 — Created July 7, 2017 and submitted

Review Board

The existing implementation of diff expansion in reviews used
JavaScript-side animations for expanding the collapsed expansion
controls in a diff on hover. As the controls expanded, the content below
the diff would get pushed down. This caused a lot of rendering on the
page, which could be slow and made scrolling through the review request
page a bit more tedious.

The new implementation uses CSS transforms and transitions to shift and
scale the controls and the diff header, which allows us to expand
outward from the diff without impacting the position of the diff itself
or any of the content below it on the page. This is much faster,
resulting in a smoother animation and less jumpiness on the page.

To do this, we begin the diff fragments in a collapsed state, scaling
down the controls and shifting the diff header down by the same amount.
We do this without transitions. After it's been loaded and scaled down,
transitions are enabled, which will then start taking place when the
user hovers.

Tested on Chrome, Firefox, and IE9+.

Tested with transitions fully disabled to make sure functionality
still worked.

Tested with diffs containing headers just above, just below, both
above and below, and neither above nor below.

Loading file attachments...

  • 0
  • 0
  • 11
  • 0
  • 11
Description From Last Updated
  1. Woo! This is awesome.

    I have just a few formatting comments for the JS.

  2. Can be _showControls(diffEls) {

  3. Can be _hideControls(diffEls) {

  4. Don't need the ()s around the variable name when there's only one arg.

    1. Ah, yeah. I'm in the habit of putting it since the single argument version is the only version that doesn't require parens, and I like the consistency. (Been seeing parens used for single arguments in some of the code I've recently been using in a side project as well -- really wish ES6 required them when doing { .. }, honestly.)

  5. /**

    Mind also fixing up the format of this comment to be summary/description?

  6. This can be one-lined:

    _.defer(() => $container.addClass('allow-transitions'));
  7. _tryShowControlsDelayed(diffEls)

  8. _tryHideControlsDelayed(diffEls)

  1. Are you a wizard

  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (bb3f23d)