OLD | NEW |
1 <!-- | 1 <!-- |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 --> | 5 --> |
6 <import src="shadow.sky" as="shadow" /> | 6 <import src="shadow.sky" as="shadow" /> |
7 <import src="sky-element.sky" /> | 7 <import src="sky-element.sky" /> |
8 <import src="sky-scrollable.sky" /> | 8 <import src="sky-scrollable.sky" /> |
9 | 9 |
10 <sky-element attributes="level:number"> | 10 <sky-element attributes="level:number"> |
(...skipping 126 matching lines...) Loading... |
137 if (!_animation.isAnimating) | 137 if (!_animation.isAnimating) |
138 _settle(); | 138 _settle(); |
139 } | 139 } |
140 | 140 |
141 void _handlePointerCancel(_) { | 141 void _handlePointerCancel(_) { |
142 if (!_animation.isAnimating) | 142 if (!_animation.isAnimating) |
143 _settle(); | 143 _settle(); |
144 } | 144 } |
145 | 145 |
146 void _handleFlingStart(event) { | 146 void _handleFlingStart(event) { |
147 double direction = event.velocityX.sign(); | 147 double direction = event.velocityX.sign; |
148 double velocityX = event.velocityX.abs() / 1000; | 148 double velocityX = event.velocityX.abs() / 1000; |
149 if (velocityX < _kMinFlingVelocity) | 149 if (velocityX < _kMinFlingVelocity) |
150 return; | 150 return; |
151 double targetPosition = direction < 0.0 ? -kWidth : 0.0; | 151 double targetPosition = direction < 0.0 ? -kWidth : 0.0; |
152 double currentPosition = _position; | 152 double currentPosition = _position; |
153 double distance = (targetPosition - currentPosition).abs(); | 153 double distance = (targetPosition - currentPosition).abs(); |
154 double duration = distance / velocityX; | 154 double duration = distance / velocityX; |
155 _animation.start( | 155 _animation.start( |
156 begin: currentPosition, | 156 begin: currentPosition, |
157 end: targetPosition, | 157 end: targetPosition, |
158 duration: duration, | 158 duration: duration, |
159 curve: linear); | 159 curve: linear); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 _init(script) => register(script, SkyDrawer); | 163 _init(script) => register(script, SkyDrawer); |
164 </script> | 164 </script> |
165 </sky-element> | 165 </sky-element> |
OLD | NEW |