W3cubDocs

/Dart 2

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();
  }
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-html/Element/scrollIntoView.html