| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated | 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated |
| 8 // functionality. | 8 // functionality. |
| 9 class _ChildrenElementList implements List { | 9 class _ChildrenElementList implements List { |
| 10 // Raw Element. | 10 // Raw Element. |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 * deprecated and will simply return this [Element] object. | 768 * deprecated and will simply return this [Element] object. |
| 769 * | 769 * |
| 770 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html | 770 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html |
| 771 * [x-tags]: http://x-tags.org/ | 771 * [x-tags]: http://x-tags.org/ |
| 772 */ | 772 */ |
| 773 $if DART2JS | 773 $if DART2JS |
| 774 @Creates('Null') // Set from Dart code; does not instantiate a native type. | 774 @Creates('Null') // Set from Dart code; does not instantiate a native type. |
| 775 $endif | 775 $endif |
| 776 var xtag; | 776 var xtag; |
| 777 | 777 |
| 778 /** |
| 779 * Scrolls this element into view. |
| 780 * |
| 781 * Only one of of the alignment options may be specified at a time. |
| 782 * |
| 783 * If no options are specified then this will attempt to scroll the minimum |
| 784 * amount needed to bring the element into view. |
| 785 * |
| 786 * Note that alignCenter is currently only supported on WebKit platforms. If |
| 787 * alignCenter is specified but not supported then this will fall back to |
| 788 * alignTop. |
| 789 * |
| 790 * See also: |
| 791 * |
| 792 * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoV
iew) |
| 793 * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scr
ollIntoViewIfNeeded) |
| 794 */ |
| 795 void scrollIntoView([ScrollIntoViewAlignment alignment]) { |
| 796 var hasScrollIntoViewIfNeeded = false; |
| 797 $if DART2JS |
| 798 hasScrollIntoViewIfNeeded = |
| 799 JS('bool', '!!(#.scrollIntoViewIfNeeded)', this); |
| 800 $endif |
| 801 if (alignment == ScrollIntoViewAlignment.TOP) { |
| 802 this.$dom_scrollIntoView(true); |
| 803 } else if (alignment == ScrollIntoViewAlignment.BOTTOM) { |
| 804 this.$dom_scrollIntoView(false); |
| 805 } else if (hasScrollIntoViewIfNeeded) { |
| 806 if (alignment == ScrollIntoViewAlignment.CENTER) { |
| 807 this.$dom_scrollIntoViewIfNeeded(true); |
| 808 } else { |
| 809 this.$dom_scrollIntoViewIfNeeded(); |
| 810 } |
| 811 } else { |
| 812 this.$dom_scrollIntoView(); |
| 813 } |
| 814 } |
| 815 |
| 778 $if DART2JS | 816 $if DART2JS |
| 779 @DomName('Element.mouseWheelEvent') | 817 @DomName('Element.mouseWheelEvent') |
| 780 static const EventStreamProvider<WheelEvent> mouseWheelEvent = | 818 static const EventStreamProvider<WheelEvent> mouseWheelEvent = |
| 781 const _CustomEventStreamProvider<WheelEvent>( | 819 const _CustomEventStreamProvider<WheelEvent>( |
| 782 Element._determineMouseWheelEventType); | 820 Element._determineMouseWheelEventType); |
| 783 | 821 |
| 784 static String _determineMouseWheelEventType(EventTarget e) { | 822 static String _determineMouseWheelEventType(EventTarget e) { |
| 785 if (JS('bool', '#.onwheel !== undefined', e)) { | 823 if (JS('bool', '#.onwheel !== undefined', e)) { |
| 786 // W3C spec, and should be IE9+, but IE has a bug exposing onwheel. | 824 // W3C spec, and should be IE9+, but IE has a bug exposing onwheel. |
| 787 return 'wheel'; | 825 return 'wheel'; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 // Optimization to improve performance until the dart2js compiler inlines this | 1095 // Optimization to improve performance until the dart2js compiler inlines this |
| 1058 // method. | 1096 // method. |
| 1059 static dynamic createElement_tag(String tag) => | 1097 static dynamic createElement_tag(String tag) => |
| 1060 // Firefox may return a JS function for some types (Embed, Object). | 1098 // Firefox may return a JS function for some types (Embed, Object). |
| 1061 JS('Element|=Object', 'document.createElement(#)', tag); | 1099 JS('Element|=Object', 'document.createElement(#)', tag); |
| 1062 $else | 1100 $else |
| 1063 static Element createElement_tag(String tag) => | 1101 static Element createElement_tag(String tag) => |
| 1064 document.$dom_createElement(tag); | 1102 document.$dom_createElement(tag); |
| 1065 $endif | 1103 $endif |
| 1066 } | 1104 } |
| 1105 |
| 1106 |
| 1107 /** |
| 1108 * Options for Element.scrollIntoView. |
| 1109 */ |
| 1110 class ScrollIntoViewAlignment { |
| 1111 final _value; |
| 1112 const ScrollIntoViewAlignment._internal(this._value); |
| 1113 toString() => 'ScrollIntoViewAlignment.$_value'; |
| 1114 |
| 1115 /// Attempt to align the element to the top of the scrollable area. |
| 1116 static const TOP = const ScrollIntoViewAlignment._internal('TOP'); |
| 1117 /// Attempt to center the element in the scrollable area. |
| 1118 static const CENTER = const ScrollIntoViewAlignment._internal('CENTER'); |
| 1119 /// Attempt to align the element to the bottom of the scrollable area. |
| 1120 static const BOTTOM = const ScrollIntoViewAlignment._internal('BOTTOM'); |
| 1121 } |
| OLD | NEW |