Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(915)

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 12226129: Updating Element.scrollIntoView to be platform independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index fb6a963c1f3db8bbcd9fd94d2abc0c7b6fcc30a2..c5cc6d3f001de62f822403e8205e2f969eb9addf 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -9721,6 +9721,46 @@ abstract class Element extends Node implements ElementTraversal {
*/
var xtag;
+ /**
+ * 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:
+ *
+ * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoView)
+ * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded)
+ */
+ void scrollIntoView({bool alignCenter, bool alignTop, bool alignBottom}) {
+ var paramCount = (alignCenter != null ? 1 : 0) +
+ (alignTop != null ? 1 : 0) + (alignBottom != null ? 1 : 0);
+ if (paramCount > 1) {
+ throw new ArgumentError(
+ 'Can only specify one of alignCenter, alignTop, alignBottom');
+ }
+ var scrollIntoViewIfNeeded = false;
+ if (alignTop != null) {
+ this.$dom_scrollIntoView(alignTop);
+ } else if (alignBottom != null) {
+ this.$dom_scrollIntoView(alignBottom);
+ } else if (scrollIntoViewIfNeeded) {
+ if (alignCenter != null) {
+ this.$dom_scrollIntoViewIfNeeded(alignCenter);
+ } else {
+ this.$dom_scrollIntoViewIfNeeded();
+ }
+ } else {
+ this.$dom_scrollIntoView();
+ }
+ }
+
Element.internal() : super.internal();
@@ -10160,7 +10200,24 @@ abstract class Element extends Node implements ElementTraversal {
@DocsEditable
void scrollByPages(int pages) native "Element_scrollByPages_Callback";
- void scrollIntoView([bool centerIfNeeded]) {
+ void $dom_scrollIntoView([bool alignWithTop]) {
+ if (?alignWithTop) {
+ _scrollIntoView_1(alignWithTop);
+ return;
+ }
+ _scrollIntoView_2();
+ return;
+ }
+
+ @DomName('Element._scrollIntoView_1')
+ @DocsEditable
+ void _scrollIntoView_1(alignWithTop) native "Element__scrollIntoView_1_Callback";
+
+ @DomName('Element._scrollIntoView_2')
+ @DocsEditable
+ void _scrollIntoView_2() native "Element__scrollIntoView_2_Callback";
+
+ void $dom_scrollIntoViewIfNeeded([bool centerIfNeeded]) {
if (?centerIfNeeded) {
_scrollIntoViewIfNeeded_1(centerIfNeeded);
return;

Powered by Google App Engine
This is Rietveld 408576698