OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 touch; | 5 part of touch; |
6 | 6 |
7 /** | 7 /** |
8 * Implementation of a scrollbar for the custom scrolling behavior | 8 * Implementation of a scrollbar for the custom scrolling behavior |
9 * defined in [:Scroller:]. | 9 * defined in [:Scroller:]. |
10 */ | 10 */ |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // DOM drive. | 124 // DOM drive. |
125 _frame.onClick.listen((Event e) { | 125 _frame.onClick.listen((Event e) { |
126 // Always focus on click as one of our children isn't all focused. | 126 // Always focus on click as one of our children isn't all focused. |
127 if (!_frame.contains(document.activeElement)) { | 127 if (!_frame.contains(document.activeElement)) { |
128 scrollerEl.focus(); | 128 scrollerEl.focus(); |
129 } | 129 } |
130 }); | 130 }); |
131 _frame.onMouseOver.listen((Event e) { | 131 _frame.onMouseOver.listen((Event e) { |
132 final activeElement = document.activeElement; | 132 final activeElement = document.activeElement; |
133 // TODO(jacobr): don't steal focus from a child element or a truly | 133 // TODO(jacobr): don't steal focus from a child element or a truly |
134 // focusable element. Only support stealing focus ffrom another | 134 // focusable element. Only support stealing focus from another |
135 // element that was given fake focus. | 135 // element that was given fake focus. |
136 if (activeElement is BodyElement || | 136 if (activeElement is BodyElement || |
137 (!_frame.contains(activeElement) && activeElement is DivElement)) { | 137 (!_frame.contains(activeElement) && activeElement is DivElement)) { |
138 scrollerEl.focus(); | 138 scrollerEl.focus(); |
139 } | 139 } |
140 if (_hovering == false) { | 140 if (_hovering == false) { |
141 _hovering = true; | 141 _hovering = true; |
142 _cancelTimeout(); | 142 _cancelTimeout(); |
143 _showScrollbars(true); | 143 _showScrollbars(true); |
144 refresh(); | 144 refresh(); |
145 } | 145 } |
146 }); | 146 }); |
147 _frame.onMouseOut.listen((e) { | 147 _frame.onMouseOut.listen((e) { |
148 _hovering = false; | 148 _hovering = false; |
149 // Start hiding immediately if we aren't | 149 // Start hiding immediately if we aren't |
150 // scrolling or already in the process of | 150 // scrolling or already in the process of |
151 // hidng the scrollbar | 151 // hiding the scrollbar |
152 if (!_scrollInProgress && _timer == null) { | 152 if (!_scrollInProgress && _timer == null) { |
153 _boundHideFn(); | 153 _boundHideFn(); |
154 } | 154 } |
155 }); | 155 }); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 void _onStart(/*MouseEvent | Touch*/ e) { | 159 void _onStart(/*MouseEvent | Touch*/ e) { |
160 Element elementOver = e.target; | 160 Element elementOver = e.target; |
161 if (elementOver == _verticalElement || elementOver == _horizontalElement) { | 161 if (elementOver == _verticalElement || elementOver == _horizontalElement) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 style.setProperty(cssPos, '${pos}px', ''); | 342 style.setProperty(cssPos, '${pos}px', ''); |
343 if (_cachedSize[cssSize] != size) { | 343 if (_cachedSize[cssSize] != size) { |
344 _cachedSize[cssSize] = size; | 344 _cachedSize[cssSize] = size; |
345 style.setProperty(cssSize, '${size}px', ''); | 345 style.setProperty(cssSize, '${size}px', ''); |
346 } | 346 } |
347 if (element.parent == null) { | 347 if (element.parent == null) { |
348 _frame.nodes.add(element); | 348 _frame.nodes.add(element); |
349 } | 349 } |
350 } | 350 } |
351 } | 351 } |
OLD | NEW |