Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: samples/swarm/swarm_ui_lib/touch/Momentum.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * Implementations can be used to simulate the deceleration of an element within 8 * Implementations can be used to simulate the deceleration of an element within
9 * a certain region. To use this behavior you need to provide an initial 9 * a certain region. To use this behavior you need to provide an initial
10 * velocity that is meant to represent the gesture that is initiating this 10 * velocity that is meant to represent the gesture that is initiating this
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 /** 473 /**
474 * Update the x, y values of the element offset without actually moving the 474 * Update the x, y values of the element offset without actually moving the
475 * element. This is done because we store decimal values for x, y for 475 * element. This is done because we store decimal values for x, y for
476 * precision, but moving is only required when the offset is changed by at 476 * precision, but moving is only required when the offset is changed by at
477 * least a whole integer. 477 * least a whole integer.
478 */ 478 */
479 void _stepWithoutAnimation() { 479 void _stepWithoutAnimation() {
480 physicsX.step(); 480 physicsX.step();
481 physicsY.step(); 481 physicsY.step();
482 // TODO(jacobr): double.round() should return an int, see b/5121907 482 _nextX = physicsX._currentOffset.round();
483 _nextX = physicsX._currentOffset.round().toInt(); 483 _nextY = physicsY._currentOffset.round();
484 _nextY = physicsY._currentOffset.round().toInt();
485 } 484 }
486 485
487 /** 486 /**
488 * Calculate the next offset of the element and animate it to that position. 487 * Calculate the next offset of the element and animate it to that position.
489 */ 488 */
490 void _step(num timestamp) { 489 void _step(num timestamp) {
491 _stepTimeout = null; 490 _stepTimeout = null;
492 491
493 // Prune moves that are more than 1 frame behind when we have more 492 // Prune moves that are more than 1 frame behind when we have more
494 // available moves. 493 // available moves.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 547
549 Coordinate get destination { 548 Coordinate get destination {
550 if (!_moves.isEmpty) { 549 if (!_moves.isEmpty) {
551 final lastMove = _moves.last; 550 final lastMove = _moves.last;
552 return new Coordinate(lastMove.x, lastMove.y); 551 return new Coordinate(lastMove.x, lastMove.y);
553 } else { 552 } else {
554 return null; 553 return null;
555 } 554 }
556 } 555 }
557 } 556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698