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

Side by Side Diff: samples/swarm/swarm_ui_lib/touch/Scroller.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 * Implementation of a custom scrolling behavior. 8 * Implementation of a custom scrolling behavior.
9 * This behavior overrides native scrolling for an area. This area can be a 9 * This behavior overrides native scrolling for an area. This area can be a
10 * single defined part of a page, the entire page, or several different parts 10 * single defined part of a page, the entire page, or several different parts
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 decelerationFactor), 344 decelerationFactor),
345 decelerationFactor); 345 decelerationFactor);
346 onDecelStart.dispatch(new Event(ScrollerEventType.DECEL_START)); 346 onDecelStart.dispatch(new Event(ScrollerEventType.DECEL_START));
347 } 347 }
348 }); 348 });
349 } 349 }
350 350
351 void throwDelta(num deltaX, num deltaY, [num decelerationFactor = null]) { 351 void throwDelta(num deltaX, num deltaY, [num decelerationFactor = null]) {
352 Coordinate start = _contentOffset; 352 Coordinate start = _contentOffset;
353 Coordinate end = currentTarget; 353 Coordinate end = currentTarget;
354 int x = end.x.toInt(); 354 int x = end.x.truncate();
355 int y = end.y.toInt(); 355 int y = end.y.truncate();
356 // If we are throwing in the opposite direction of the existing momentum, 356 // If we are throwing in the opposite direction of the existing momentum,
357 // cancel the current momentum. 357 // cancel the current momentum.
358 if (deltaX != 0 && deltaX.isNegative != (end.x - start.x).isNegative) { 358 if (deltaX != 0 && deltaX.isNegative != (end.x - start.x).isNegative) {
359 x = start.x; 359 x = start.x;
360 } 360 }
361 if (deltaY != 0 && deltaY.isNegative != (end.y - start.y).isNegative) { 361 if (deltaY != 0 && deltaY.isNegative != (end.y - start.y).isNegative) {
362 y = start.y; 362 y = start.y;
363 } 363 }
364 x += deltaX.toInt(); 364 x += deltaX.truncate();
365 y += deltaY.toInt(); 365 y += deltaY.truncate();
366 throwTo(x, y, decelerationFactor); 366 throwTo(x, y, decelerationFactor);
367 } 367 }
368 368
369 void setPosition(num x, num y) { 369 void setPosition(num x, num y) {
370 _momentum.abort(); 370 _momentum.abort();
371 _contentOffset.x = x; 371 _contentOffset.x = x;
372 _contentOffset.y = y; 372 _contentOffset.y = y;
373 _snapContentOffsetToBounds(); 373 _snapContentOffsetToBounds();
374 _setContentOffset(_contentOffset.x, _contentOffset.y); 374 _setContentOffset(_contentOffset.x, _contentOffset.y);
375 } 375 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 for (EventListener listener in _listeners) { 715 for (EventListener listener in _listeners) {
716 listener(evt); 716 listener(evt);
717 } 717 }
718 } 718 }
719 } 719 }
720 720
721 class ScrollerScrollTechnique { 721 class ScrollerScrollTechnique {
722 static const TRANSFORM_3D = 1; 722 static const TRANSFORM_3D = 1;
723 static const RELATIVE_POSITIONING = 2; 723 static const RELATIVE_POSITIONING = 2;
724 } 724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698