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 * Implementation of a custom scrolling behavior. | 6 * Implementation of a custom scrolling behavior. |
7 * This behavior overrides native scrolling for an area. This area can be a | 7 * This behavior overrides native scrolling for an area. This area can be a |
8 * single defined part of a page, the entire page, or several different parts | 8 * single defined part of a page, the entire page, or several different parts |
9 * of a page. | 9 * of a page. |
10 * | 10 * |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 }); | 346 }); |
347 } | 347 } |
348 | 348 |
349 void throwDelta(num deltaX, num deltaY, [num decelerationFactor = null]) { | 349 void throwDelta(num deltaX, num deltaY, [num decelerationFactor = null]) { |
350 Coordinate start = _contentOffset; | 350 Coordinate start = _contentOffset; |
351 Coordinate end = currentTarget; | 351 Coordinate end = currentTarget; |
352 int x = end.x.toInt(); | 352 int x = end.x.toInt(); |
353 int y = end.y.toInt(); | 353 int y = end.y.toInt(); |
354 // If we are throwing in the opposite direction of the existing momentum, | 354 // If we are throwing in the opposite direction of the existing momentum, |
355 // cancel the current momentum. | 355 // cancel the current momentum. |
356 if (deltaX != 0 && deltaX.isNegative() != (end.x - start.x).isNegative()) { | 356 if (deltaX != 0 && deltaX.isNegative != (end.x - start.x).isNegative) { |
357 x = start.x; | 357 x = start.x; |
358 } | 358 } |
359 if (deltaY != 0 && deltaY.isNegative() != (end.y - start.y).isNegative()) { | 359 if (deltaY != 0 && deltaY.isNegative != (end.y - start.y).isNegative) { |
360 y = start.y; | 360 y = start.y; |
361 } | 361 } |
362 x += deltaX.toInt(); | 362 x += deltaX.toInt(); |
363 y += deltaY.toInt(); | 363 y += deltaY.toInt(); |
364 throwTo(x, y, decelerationFactor); | 364 throwTo(x, y, decelerationFactor); |
365 } | 365 } |
366 | 366 |
367 void setPosition(num x, num y) { | 367 void setPosition(num x, num y) { |
368 _momentum.abort(); | 368 _momentum.abort(); |
369 _contentOffset.x = x; | 369 _contentOffset.x = x; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 for (EventListener listener in _listeners) { | 722 for (EventListener listener in _listeners) { |
723 listener(evt); | 723 listener(evt); |
724 } | 724 } |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 class ScrollerScrollTechnique { | 728 class ScrollerScrollTechnique { |
729 static const TRANSFORM_3D = 1; | 729 static const TRANSFORM_3D = 1; |
730 static const RELATIVE_POSITIONING = 2; | 730 static const RELATIVE_POSITIONING = 2; |
731 } | 731 } |
OLD | NEW |