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

Unified Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

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:
View side-by-side diff with in-line comments
Download patch
« sdk/lib/html/dartium/html_dartium.dart ('K') | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_Element.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index 47f53c1499bb9d69bbeef8a90b6b01a4730e170c..6eaee82e28648711977bdda3f7c4155931a2f858 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -775,6 +775,44 @@ $if DART2JS
$endif
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;
+$if DART2JS
+ hasScrollIntoViewIfNeeded =
+ JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
+$endif
+ 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();
+ }
+ }
+
$if DART2JS
@DomName('Element.mouseWheelEvent')
static const EventStreamProvider<WheelEvent> mouseWheelEvent =
@@ -1064,3 +1102,20 @@ $else
document.$dom_createElement(tag);
$endif
}
+
+
+/**
+ * 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');
+}
« sdk/lib/html/dartium/html_dartium.dart ('K') | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698