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 * Implementations can be used to simulate the deceleration of an element within | 6 * Implementations can be used to simulate the deceleration of an element within |
7 * a certain region. To use this behavior you need to provide an initial | 7 * a certain region. To use this behavior you need to provide an initial |
8 * velocity that is meant to represent the gesture that is initiating this | 8 * velocity that is meant to represent the gesture that is initiating this |
9 * deceleration. You also provide the bounds of the region that the element | 9 * deceleration. You also provide the bounds of the region that the element |
10 * exists in, and the current offset of the element within that region. The | 10 * exists in, and the current offset of the element within that region. The |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 num _stepTimeout; | 373 num _stepTimeout; |
374 bool _decelerating; | 374 bool _decelerating; |
375 MomentumDelegate _delegate; | 375 MomentumDelegate _delegate; |
376 int _nextY; | 376 int _nextY; |
377 int _nextX; | 377 int _nextX; |
378 Coordinate _minCoord; | 378 Coordinate _minCoord; |
379 Coordinate _maxCoord; | 379 Coordinate _maxCoord; |
380 num _customDecelerationFactor; | 380 num _customDecelerationFactor; |
381 num _defaultDecelerationFactor; | 381 num _defaultDecelerationFactor; |
382 | 382 |
383 TimeoutMomentum(this._delegate, [defaultDecelerationFactor = 1]) | 383 TimeoutMomentum(this._delegate, [num defaultDecelerationFactor = 1]) |
384 : _defaultDecelerationFactor = defaultDecelerationFactor, | 384 : _defaultDecelerationFactor = defaultDecelerationFactor, |
385 _decelerating = false, | 385 _decelerating = false, |
386 _moves = new Queue<_Move>(), | 386 _moves = new Queue<_Move>(), |
387 physicsX = new SingleDimensionPhysics(), | 387 physicsX = new SingleDimensionPhysics(), |
388 physicsY = new SingleDimensionPhysics(); | 388 physicsY = new SingleDimensionPhysics(); |
389 | 389 |
390 /** | 390 /** |
391 * Calculate and return the moves for the deceleration motion. | 391 * Calculate and return the moves for the deceleration motion. |
392 */ | 392 */ |
393 void _calculateMoves() { | 393 void _calculateMoves() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 545 |
546 Coordinate get destination() { | 546 Coordinate get destination() { |
547 if (!_moves.isEmpty()) { | 547 if (!_moves.isEmpty()) { |
548 final lastMove = _moves.last(); | 548 final lastMove = _moves.last(); |
549 return new Coordinate(lastMove.x, lastMove.y); | 549 return new Coordinate(lastMove.x, lastMove.y); |
550 } else { | 550 } else { |
551 return null; | 551 return null; |
552 } | 552 } |
553 } | 553 } |
554 } | 554 } |
OLD | NEW |