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

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
« no previous file with comments | « 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 3f7757118294bd61bad18f0df57f535dc5400d6d..c8a56f371115dbdb072eaca81e9a3e81dab03767 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -769,6 +769,49 @@ $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({bool alignCenter, bool alignTop, bool alignBottom}) {
Jacob 2013/02/12 23:12:33 shouldn't this be an enum instead of 3 bools?
+ 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 DART2JS
+ scrollIntoViewIfNeeded = JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
+$endif
+ 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();
+ }
+ }
+
$if DART2JS
@DomName('Element.mouseWheelEvent')
static const EventStreamProvider<WheelEvent> mouseWheelEvent =
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698