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

Side by Side Diff: samples/ui_lib/touch/Scroller.dart

Issue 10919146: Get rid of a lot of () for getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « samples/ui_lib/touch/Scrollbar.dart ('k') | samples/ui_lib/touch/TouchUtil.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // TODO(jacobr): this assert fires asynchronously which could be confusing. 232 // TODO(jacobr): this assert fires asynchronously which could be confusing.
233 if (_scrollTechnique == ScrollerScrollTechnique.RELATIVE_POSITIONING) { 233 if (_scrollTechnique == ScrollerScrollTechnique.RELATIVE_POSITIONING) {
234 _element.computedStyle.then((CSSStyleDeclaration style) { 234 _element.computedStyle.then((CSSStyleDeclaration style) {
235 assert(style.position != "static"); 235 assert(style.position != "static");
236 }); 236 });
237 } 237 }
238 238
239 _initLayer(); 239 _initLayer();
240 } 240 }
241 241
242 EventListenerList get onScrollerStart() { 242 EventListenerList get onScrollerStart {
243 if (_onScrollerStart === null) { 243 if (_onScrollerStart === null) {
244 _onScrollerStart = new SimpleEventListenerList(); 244 _onScrollerStart = new SimpleEventListenerList();
245 } 245 }
246 return _onScrollerStart; 246 return _onScrollerStart;
247 } 247 }
248 248
249 EventListenerList get onScrollerEnd() { 249 EventListenerList get onScrollerEnd {
250 if (_onScrollerEnd === null) { 250 if (_onScrollerEnd === null) {
251 _onScrollerEnd = new SimpleEventListenerList(); 251 _onScrollerEnd = new SimpleEventListenerList();
252 } 252 }
253 return _onScrollerEnd; 253 return _onScrollerEnd;
254 } 254 }
255 255
256 EventListenerList get onScrollerDragEnd() { 256 EventListenerList get onScrollerDragEnd {
257 if (_onScrollerDragEnd === null) { 257 if (_onScrollerDragEnd === null) {
258 _onScrollerDragEnd = new SimpleEventListenerList(); 258 _onScrollerDragEnd = new SimpleEventListenerList();
259 } 259 }
260 return _onScrollerDragEnd; 260 return _onScrollerDragEnd;
261 } 261 }
262 262
263 EventListenerList get onContentMoved() { 263 EventListenerList get onContentMoved {
264 if (_onContentMoved === null) { 264 if (_onContentMoved === null) {
265 _onContentMoved = new SimpleEventListenerList(); 265 _onContentMoved = new SimpleEventListenerList();
266 } 266 }
267 return _onContentMoved; 267 return _onContentMoved;
268 } 268 }
269 269
270 EventListenerList get onDecelStart() { 270 EventListenerList get onDecelStart {
271 if (_onDecelStart === null) { 271 if (_onDecelStart === null) {
272 _onDecelStart = new SimpleEventListenerList(); 272 _onDecelStart = new SimpleEventListenerList();
273 } 273 }
274 return _onDecelStart; 274 return _onDecelStart;
275 } 275 }
276 276
277 277
278 /** 278 /**
279 * Add a scroll listener. This allows other classes to subscribe to scroll 279 * Add a scroll listener. This allows other classes to subscribe to scroll
280 * notifications from this scroller. 280 * notifications from this scroller.
(...skipping 20 matching lines...) Expand all
301 if (newPosition > maxPosition) { 301 if (newPosition > maxPosition) {
302 newPosition -= (newPosition - maxPosition) / 2; 302 newPosition -= (newPosition - maxPosition) / 2;
303 } 303 }
304 } 304 }
305 return newPosition; 305 return newPosition;
306 } 306 }
307 307
308 /** 308 /**
309 * Coordinate we would end up at if we did nothing. 309 * Coordinate we would end up at if we did nothing.
310 */ 310 */
311 Coordinate get currentTarget() { 311 Coordinate get currentTarget {
312 Coordinate end = _momentum.destination; 312 Coordinate end = _momentum.destination;
313 if (end === null) { 313 if (end === null) {
314 end = _contentOffset; 314 end = _contentOffset;
315 } 315 }
316 return end; 316 return end;
317 } 317 }
318 318
319 Coordinate get contentOffset() => _contentOffset; 319 Coordinate get contentOffset => _contentOffset;
320 320
321 /** 321 /**
322 * Animate the position of the scroller to the specified [x], [y] coordinates 322 * Animate the position of the scroller to the specified [x], [y] coordinates
323 * by applying the throw gesture with the correct velocity to end at that 323 * by applying the throw gesture with the correct velocity to end at that
324 * location. 324 * location.
325 */ 325 */
326 void throwTo(num x, num y, [num decelerationFactor = null]) { 326 void throwTo(num x, num y, [num decelerationFactor = null]) {
327 reconfigure(() { 327 reconfigure(() {
328 final snappedTarget = _snapToBounds(x, y); 328 final snappedTarget = _snapToBounds(x, y);
329 // If a deceleration factor is not specified, use the existing 329 // If a deceleration factor is not specified, use the existing
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 * none is provided then the content's current x offset will be used. 391 * none is provided then the content's current x offset will be used.
392 * Returns the percent of the page scrolled horizontally. 392 * Returns the percent of the page scrolled horizontally.
393 */ 393 */
394 num getHorizontalScrollPercent([num x = null]) { 394 num getHorizontalScrollPercent([num x = null]) {
395 x = x !== null ? x : _contentOffset.x; 395 x = x !== null ? x : _contentOffset.x;
396 return (x - _minPoint.x) / (_maxPoint.x - _minPoint.x); 396 return (x - _minPoint.x) / (_maxPoint.x - _minPoint.x);
397 } 397 }
398 398
399 num getMaxPointY()=> _maxPoint.y; 399 num getMaxPointY()=> _maxPoint.y;
400 num getMinPointY() => _minPoint.y; 400 num getMinPointY() => _minPoint.y;
401 Momentum get momentum() => _momentum; 401 Momentum get momentum => _momentum;
402 402
403 /** 403 /**
404 * Provide access to the touch handler that the scroller created to manage 404 * Provide access to the touch handler that the scroller created to manage
405 * touch events. 405 * touch events.
406 */ 406 */
407 TouchHandler getTouchHandler() => _touchHandler; 407 TouchHandler getTouchHandler() => _touchHandler;
408 num getVerticalOffset() => _contentOffset.y; 408 num getVerticalOffset() => _contentOffset.y;
409 409
410 /** 410 /**
411 * [y] value is used as reference for percent measurement. If 411 * [y] value is used as reference for percent measurement. If
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « samples/ui_lib/touch/Scrollbar.dart ('k') | samples/ui_lib/touch/TouchUtil.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698