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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.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/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 066b61e898bc065d122296463caa4fd7572edead..b957969d6107824495190770ef13c5b903551953 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -8961,6 +8961,47 @@ 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({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;
+ scrollIntoViewIfNeeded = JS('bool', '!!(#.scrollIntoViewIfNeeded)', this);
+ 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();
+ }
+ }
+
@DomName('Element.mouseWheelEvent')
static const EventStreamProvider<WheelEvent> mouseWheelEvent =
const _CustomEventStreamProvider<WheelEvent>(
@@ -9566,10 +9607,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')
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('J')

Powered by Google App Engine
This is Rietveld 408576698