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

Unified Diff: sdk/lib/html/dartium/html_dartium.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 | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/element_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5cd9207bf85cc3fc9dfb8171fd8cc1fce776b33..f110817795f2feb0a581aace3fc0fc003e8e74b3 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -9727,6 +9727,40 @@ 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([ScrollIntoViewAlignment alignment]) {
Jacob 2013/02/13 21:08:19 Why not call ScrollIntoViewAlignment just Anchor
+ var hasScrollIntoViewIfNeeded = false;
+ 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();
+ }
+ }
+
Element.internal() : super.internal();
@@ -10166,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;
@@ -10552,6 +10603,23 @@ class _ElementFactoryProvider {
document.$dom_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');
+}
+
@DocsEditable
@deprecated
class ElementEvents extends Events {
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698