scrollIntoView method

void scrollIntoView ([ScrollAlignment alignment ])

Scrolls this element into view.

Only one of of the alignment options may be specified at a time.

If no options are specified then this will attempt to scroll the minimum amount needed to bring the element into view.

Note that alignCenter is currently only supported on WebKit platforms. If alignCenter is specified but not supported then this will fall back to alignTop.

See also:

Implementation

void scrollIntoView([ScrollAlignment alignment]) {
  var hasScrollIntoViewIfNeeded = true;
  hasScrollIntoViewIfNeeded =
      JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
  if (alignment == ScrollAlignment.TOP) {
    this._scrollIntoView(true);
  } else if (alignment == ScrollAlignment.BOTTOM) {
    this._scrollIntoView(false);
  } else if (hasScrollIntoViewIfNeeded) {
    if (alignment == ScrollAlignment.CENTER) {
      this._scrollIntoViewIfNeeded(true);
    } else {
      this._scrollIntoViewIfNeeded();
    }
  } else {
    this._scrollIntoView();
  }
}