Chromium Code Reviews| 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 = |