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 /** | 5 /** |
6 * Click buster implementation, which is a behavior that prevents native clicks | 6 * Click buster implementation, which is a behavior that prevents native clicks |
7 * from firing at undesirable times. There are two scenarios where we may want | 7 * from firing at undesirable times. There are two scenarios where we may want |
8 * to 'bust' a click. | 8 * to 'bust' a click. |
9 * | 9 * |
10 * Buttons implemented with touch events usually have click handlers as well. | 10 * Buttons implemented with touch events usually have click handlers as well. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // temporary "allowable zone". | 168 // temporary "allowable zone". |
169 // - preventGhostClick is called and removes the "allowable zone". | 169 // - preventGhostClick is called and removes the "allowable zone". |
170 // - The click handler captures the user's click event and prevents it | 170 // - The click handler captures the user's click event and prevents it |
171 // from propagating since there is no "allowable zone". | 171 // from propagating since there is no "allowable zone". |
172 // | 172 // |
173 // 3) User performs a should-not-be-busted click. | 173 // 3) User performs a should-not-be-busted click. |
174 // - touchstart event triggers the attached handler and creates a | 174 // - touchstart event triggers the attached handler and creates a |
175 // temporary "allowable zone". | 175 // temporary "allowable zone". |
176 // - The click handler captures the user's click event and allows it to | 176 // - The click handler captures the user's click event and allows it to |
177 // propagate since the click falls in the "allowable zone". | 177 // propagate since the click falls in the "allowable zone". |
178 if (_coordinates === null) { | 178 if (_coordinates == null) { |
179 // Listen to clicks on capture phase so they can be busted before anything | 179 // Listen to clicks on capture phase so they can be busted before anything |
180 // else gets a chance to handle them. | 180 // else gets a chance to handle them. |
181 document.on.click.add((e) { _onClick(e); }, true); | 181 document.on.click.add((e) { _onClick(e); }, true); |
182 document.on.focus.add((e) { _lastPreventedTime = 0; }, true); | 182 document.on.focus.add((e) { _lastPreventedTime = 0; }, true); |
183 | 183 |
184 // Listen to touchstart on capture phase since it must be called prior to | 184 // Listen to touchstart on capture phase since it must be called prior to |
185 // every click or else we will accidentally prevent the click even if we | 185 // every click or else we will accidentally prevent the click even if we |
186 // don't call preventGhostClick. | 186 // don't call preventGhostClick. |
187 Function startFn = (e) { _onTouchStart(e); }; | 187 Function startFn = (e) { _onTouchStart(e); }; |
188 if (!Device.supportsTouch) { | 188 if (!Device.supportsTouch) { |
(...skipping 16 matching lines...) Expand all Loading... |
205 if (_hitTest(entry.element, entry.nextEntry().element, x, y)) { | 205 if (_hitTest(entry.element, entry.nextEntry().element, x, y)) { |
206 entry.nextEntry().remove(); | 206 entry.nextEntry().remove(); |
207 entry.remove(); | 207 entry.remove(); |
208 return; | 208 return; |
209 } else { | 209 } else { |
210 entry = entry.nextEntry().nextEntry(); | 210 entry = entry.nextEntry().nextEntry(); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 } | 214 } |
OLD | NEW |