(bug 25830) fix JS preview causing the page to "jump"
authorMatmaRex <matma.rex@gmail.com>
Thu, 9 Aug 2012 13:51:28 +0000 (15:51 +0200)
committerMatmaRex <matma.rex@gmail.com>
Fri, 31 Aug 2012 23:07:31 +0000 (01:07 +0200)
commitb12dc64a1198f6b094a5a60307412ff91f0bbf49
tree820e93e42c165ed5c77acb56fda56a730620dc3f
parent02762b56fe72eeed4d63e46a4e14affc4c6ba3bb
(bug 25830) fix JS preview causing the page to "jump"

Originally a patch by DieBuche <diebuche@gmail.com>, fixed to apply on
master (only whitespace changes were needed), with multiple new tweaks and
fixes.

The patch introduces fadeTo(..., 0.4) instead of fadeIn/fadeOut, causing
the preview not to be removed, but only faded out slightly. The reason
for this change is twofold:
* We do not want to completely remove the elements, which is what the old
  version did. This causes the edit field to jump up and then back down
  when the preview is reinserted.
* We do not want to display a huge blank white space where the preview
  used to be before it disappeared.

Instead of scrolling to the top, we scroll straight to the preview. This
works when the preview is set to appear below edit field and possibly with
non-default skins. (And also is much neater.) Thanks to Jdlrobson for
noticing this issue.

We also separately handle first preview and all the following ones to
further reduce jumping. Thanks to MarkTraceur and Kaldari for noticing the
problem and to Kaldari for a patch.

Change-Id: I743ed45e039445242a99a23cad719a75731c5562
skins/common/preview.js