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

Side by Side Diff: sky/framework/components/scrollable.dart

Issue 1097373002: [Effen] Prevent scrolling past the bottom of a scrollable list. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move the creation of the OverscrollBehavior class to FixedHeightScrollable, since we already assumeā€¦ Created 5 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import '../animation/generators.dart'; 5 import '../animation/generators.dart';
6 import '../animation/mechanics.dart'; 6 import '../animation/mechanics.dart';
7 import '../animation/scroll_behavior.dart'; 7 import '../animation/scroll_behavior.dart';
8 import '../fn.dart'; 8 import '../fn.dart';
9 import '../theme/view-configuration.dart' as config; 9 import '../theme/view-configuration.dart' as config;
10 import 'dart:math' as math; 10 import 'dart:math' as math;
11 import 'dart:sky' as sky; 11 import 'dart:sky' as sky;
12 12
13 const double _kMillisecondsPerSecond = 1000.0; 13 const double _kMillisecondsPerSecond = 1000.0;
14 14
15 double _velocityForFlingGesture(sky.GestureEvent event) { 15 double _velocityForFlingGesture(sky.GestureEvent event) {
16 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, 16 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity,
17 -event.velocityY)) / _kMillisecondsPerSecond; 17 -event.velocityY)) / _kMillisecondsPerSecond;
18 } 18 }
19 19
20 abstract class ScrollClient { 20 abstract class ScrollClient {
21 bool ancestorScrolled(Scrollable ancestor); 21 bool ancestorScrolled(Scrollable ancestor);
22 } 22 }
23 23
24 abstract class Scrollable extends Component { 24 abstract class Scrollable extends Component {
25 ScrollBehavior scrollBehavior; 25
26 double _scrollOffset = 0.0;
26 double get scrollOffset => _scrollOffset; 27 double get scrollOffset => _scrollOffset;
27 28
28 double _scrollOffset = 0.0; 29 ScrollBehavior _scrollBehavior;
30 ScrollBehavior createScrollBehavior();
31 ScrollBehavior get scrollBehavior {
32 if (_scrollBehavior == null)
33 _scrollBehavior = createScrollBehavior();
34 return _scrollBehavior;
35 }
36
29 Simulation _simulation; 37 Simulation _simulation;
30 38
31 Scrollable({Object key, this.scrollBehavior}) : super(key: key) { 39 Scrollable({Object key}) : super(key: key) {
32 onDidUnmount(_stopSimulation); 40 onDidUnmount(_stopSimulation);
33 } 41 }
34 42
35 UINode buildContent(); 43 UINode buildContent();
36 44
37 UINode build() { 45 UINode build() {
38 return new EventListenerNode( 46 return new EventListenerNode(
39 buildContent(), 47 buildContent(),
40 onPointerDown: _handlePointerDown, 48 onPointerDown: _handlePointerDown,
41 onPointerUp: _handlePointerUpOrCancel, 49 onPointerUp: _handlePointerUpOrCancel,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 137 }
130 138
131 void _handleFlingCancel(sky.GestureEvent event) { 139 void _handleFlingCancel(sky.GestureEvent event) {
132 _startSimulation(_createParticle()); 140 _startSimulation(_createParticle());
133 } 141 }
134 142
135 void _handleWheel(sky.WheelEvent event) { 143 void _handleWheel(sky.WheelEvent event) {
136 scrollBy(-event.offsetY); 144 scrollBy(-event.offsetY);
137 } 145 }
138 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698