Add new arguments and better heuristics to $.fn.positionToSide.

Review Request #5135 — Created Dec. 17, 2013 and submitted

Information

Djblets
master

Reviewers

Add new arguments and better heuristics to $.fn.positionToSide.

positionToSide had trouble matching an element when positioned, say, to
either above/below another element, when the left or right of the
element would be scrolled off-screen. The "best guess" logic failed,
since it took into account both positions. Now it only computes the
position for the side it's checking, and leaves computing the other axis
until after it finds the best side.

There's some new options for controlling positioning as well. Instead of
just 'distance', there's now 'xDistance' and 'yDistance'. These both
fall back to using 'distance' if not specified.

'xOffset' and 'yOffset' control offseting the element in the direction
not matched up to a side. That's useful when you want to push the
element by a few pixels in one direction relative to the side.

Last, but not least, fitOnScreen now anchors things going off the top or
left of the scroll position as well, instead of just the bottom or
right.

Tested with tooltips and the comment dialog for images. They appeared as
they did before.

Turned on different sides (eventually all sides) and tested positions
at different window sizes and scroll positions and offsets and distances.
It always appeared where I expected and how I expected.

david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed