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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Side-by-side diff isn't available for this file because of its large size.
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
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | sdk/lib/html/dartium/html_dartium.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 2faa94caae37d6ee979f22802351f57845d7510f..1597f10ef2f69e04e87af1b8674c80d8bfa66c69 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -8967,6 +8967,42 @@ abstract class Element extends Node implements ElementTraversal native "*Element
@Creates('Null') // Set from Dart code; does not instantiate a native type.
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([ScrollIntoViewAlignment alignment]) {
+ var hasScrollIntoViewIfNeeded = false;
+ hasScrollIntoViewIfNeeded =
+ JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
+ if (alignment == ScrollIntoViewAlignment.TOP) {
+ this.$dom_scrollIntoView(true);
+ } else if (alignment == ScrollIntoViewAlignment.BOTTOM) {
+ this.$dom_scrollIntoView(false);
+ } else if (hasScrollIntoViewIfNeeded) {
+ if (alignment == ScrollIntoViewAlignment.CENTER) {
+ this.$dom_scrollIntoViewIfNeeded(true);
+ } else {
+ this.$dom_scrollIntoViewIfNeeded();
+ }
+ } else {
+ this.$dom_scrollIntoView();
+ }
+ }
+
@DomName('Element.mouseWheelEvent')
static const EventStreamProvider<WheelEvent> mouseWheelEvent =
const _CustomEventStreamProvider<WheelEvent>(
@@ -9572,10 +9608,15 @@ abstract class Element extends Node implements ElementTraversal native "*Element
@DocsEditable
void scrollByPages(int pages) native;
+ @JSName('scrollIntoView')
+ @DomName('Element.scrollIntoView')
+ @DocsEditable
+ void $dom_scrollIntoView([bool alignWithTop]) native;
+
@JSName('scrollIntoViewIfNeeded')
@DomName('Element.scrollIntoViewIfNeeded')
@DocsEditable
- void scrollIntoView([bool centerIfNeeded]) native;
+ void $dom_scrollIntoViewIfNeeded([bool centerIfNeeded]) native;
@JSName('setAttribute')
@DomName('Element.setAttribute')
@@ -9949,6 +9990,23 @@ class _ElementFactoryProvider {
// Firefox may return a JS function for some types (Embed, Object).
JS('Element|=Object', 'document.createElement(#)', tag);
}
+
+
+/**
+ * Options for Element.scrollIntoView.
+ */
+class ScrollIntoViewAlignment {
+ final _value;
+ const ScrollIntoViewAlignment._internal(this._value);
+ toString() => 'ScrollIntoViewAlignment.$_value';
+
+ /// Attempt to align the element to the top of the scrollable area.
+ static const TOP = const ScrollIntoViewAlignment._internal('TOP');
+ /// Attempt to center the element in the scrollable area.
+ static const CENTER = const ScrollIntoViewAlignment._internal('CENTER');
+ /// Attempt to align the element to the bottom of the scrollable area.
+ static const BOTTOM = const ScrollIntoViewAlignment._internal('BOTTOM');
+}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | sdk/lib/html/dartium/html_dartium.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698