| 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 library swipe; | 5 library swipe; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 initialize3D(); | 22 initialize3D(); |
| 23 | 23 |
| 24 // Handle touch events. | 24 // Handle touch events. |
| 25 int touchStartX; | 25 int touchStartX; |
| 26 | 26 |
| 27 target.onTouchStart.listen((TouchEvent event) { | 27 target.onTouchStart.listen((TouchEvent event) { |
| 28 event.preventDefault(); | 28 event.preventDefault(); |
| 29 | 29 |
| 30 if (event.touches.length > 0) { | 30 if (event.touches.length > 0) { |
| 31 touchStartX = event.touches[0].pageX; | 31 touchStartX = event.touches[0].page.x; |
| 32 } | 32 } |
| 33 }); | 33 }); |
| 34 | 34 |
| 35 target.onTouchMove.listen((TouchEvent event) { | 35 target.onTouchMove.listen((TouchEvent event) { |
| 36 event.preventDefault(); | 36 event.preventDefault(); |
| 37 | 37 |
| 38 if (touchStartX != null && event.touches.length > 0) { | 38 if (touchStartX != null && event.touches.length > 0) { |
| 39 int newTouchX = event.touches[0].pageX; | 39 int newTouchX = event.touches[0].page.x; |
| 40 | 40 |
| 41 if (newTouchX > touchStartX) { | 41 if (newTouchX > touchStartX) { |
| 42 spinFigure(target, (newTouchX - touchStartX) ~/ 20 + 1); | 42 spinFigure(target, (newTouchX - touchStartX) ~/ 20 + 1); |
| 43 touchStartX = null; | 43 touchStartX = null; |
| 44 } else if (newTouchX < touchStartX) { | 44 } else if (newTouchX < touchStartX) { |
| 45 spinFigure(target, (newTouchX - touchStartX) ~/ 20 - 1); | 45 spinFigure(target, (newTouchX - touchStartX) ~/ 20 - 1); |
| 46 touchStartX = null; | 46 touchStartX = null; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 }); | 49 }); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * Stop any spin that may be in progress. | 122 * Stop any spin that may be in progress. |
| 123 */ | 123 */ |
| 124 void stopSpin() { | 124 void stopSpin() { |
| 125 if (timer != null) { | 125 if (timer != null) { |
| 126 timer.cancel(); | 126 timer.cancel(); |
| 127 timer = null; | 127 timer = null; |
| 128 } | 128 } |
| 129 } | 129 } |
| OLD | NEW |