mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
[dart:html] Expose scrollIntoViewIfNeeded
`scrollIntoViewIfNeeded` is nested within `scrollIntoView`. The latter method is outdated and the way to access the different ways to call `scrollIntoViewIfNeeded`. Instead of using that method, this CL directly exposes `scrollIntoViewIfNeeded`. Change-Id: I38d7876a7923768ae165c29a98e514e90182b77e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231047 Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Riley Porter <rileyporter@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
33b3c1d6c6
commit
0ec4c3a1b5
|
@ -13389,10 +13389,14 @@ class Element extends Node
|
|||
} else if (alignment == ScrollAlignment.BOTTOM) {
|
||||
this._scrollIntoView(false);
|
||||
} else if (hasScrollIntoViewIfNeeded) {
|
||||
// TODO(srujzs): This method shouldn't be calling out to
|
||||
// `scrollIntoViewIfNeeded`. Remove this and make `scrollIntoView` match
|
||||
// the browser definition. If you intend to use `scrollIntoViewIfNeeded`,
|
||||
// use the `Element.scrollIntoViewIfNeeded` method.
|
||||
if (alignment == ScrollAlignment.CENTER) {
|
||||
this._scrollIntoViewIfNeeded(true);
|
||||
this.scrollIntoViewIfNeeded(true);
|
||||
} else {
|
||||
this._scrollIntoViewIfNeeded();
|
||||
this.scrollIntoViewIfNeeded();
|
||||
}
|
||||
} else {
|
||||
this._scrollIntoView();
|
||||
|
@ -14896,8 +14900,18 @@ class Element extends Node
|
|||
@JSName('scrollIntoView')
|
||||
void _scrollIntoView([Object? arg]) native;
|
||||
|
||||
@JSName('scrollIntoViewIfNeeded')
|
||||
void _scrollIntoViewIfNeeded([bool? centerIfNeeded]) native;
|
||||
/**
|
||||
* Nonstandard version of `scrollIntoView` that scrolls the current element
|
||||
* into the visible area of the browser window if it's not already within the
|
||||
* visible area of the browser window. If the element is already within the
|
||||
* visible area of the browser window, then no scrolling takes place.
|
||||
*
|
||||
* ## Other resources
|
||||
*
|
||||
* * [Element.scrollIntoViewIfNeeded](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded)
|
||||
* from MDN.
|
||||
*/
|
||||
void scrollIntoViewIfNeeded([bool? centerIfNeeded]) native;
|
||||
|
||||
void scrollTo([options_OR_x, num? y]) {
|
||||
if (options_OR_x == null && y == null) {
|
||||
|
|
|
@ -1270,6 +1270,19 @@
|
|||
" * See [EventStreamProvider] for usage information.",
|
||||
" */"
|
||||
],
|
||||
"scrollIntoViewIfNeeded": [
|
||||
"/**",
|
||||
" * Nonstandard version of `scrollIntoView` that scrolls the current element",
|
||||
" * into the visible area of the browser window if it's not already within the",
|
||||
" * visible area of the browser window. If the element is already within the",
|
||||
" * visible area of the browser window, then no scrolling takes place.",
|
||||
" *",
|
||||
" * ## Other resources",
|
||||
" *",
|
||||
" * * [Element.scrollIntoViewIfNeeded](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded)",
|
||||
" * from MDN.",
|
||||
" */"
|
||||
],
|
||||
"searchEvent": [
|
||||
"/**",
|
||||
" * Static factory designed to expose `search` events to event",
|
||||
|
|
|
@ -403,7 +403,6 @@ private_html_members = monitored.Set(
|
|||
'Element.getElementsByTagName',
|
||||
'Element.insertAdjacentHTML',
|
||||
'Element.scrollIntoView',
|
||||
'Element.scrollIntoViewIfNeeded',
|
||||
'Element.getAttribute',
|
||||
'Element.getAttributeNS',
|
||||
'Element.hasAttribute',
|
||||
|
|
|
@ -1007,10 +1007,14 @@ $endif
|
|||
} else if (alignment == ScrollAlignment.BOTTOM) {
|
||||
this._scrollIntoView(false);
|
||||
} else if (hasScrollIntoViewIfNeeded) {
|
||||
// TODO(srujzs): This method shouldn't be calling out to
|
||||
// `scrollIntoViewIfNeeded`. Remove this and make `scrollIntoView` match
|
||||
// the browser definition. If you intend to use `scrollIntoViewIfNeeded`,
|
||||
// use the `Element.scrollIntoViewIfNeeded` method.
|
||||
if (alignment == ScrollAlignment.CENTER) {
|
||||
this._scrollIntoViewIfNeeded(true);
|
||||
this.scrollIntoViewIfNeeded(true);
|
||||
} else {
|
||||
this._scrollIntoViewIfNeeded();
|
||||
this.scrollIntoViewIfNeeded();
|
||||
}
|
||||
} else {
|
||||
this._scrollIntoView();
|
||||
|
|
Loading…
Reference in a new issue