Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
461b1914
Commit
461b1914
authored
Sep 22, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added velocity and distance thresholds to ScrollSimulation, ScrollBehavior
parent
12097bdd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
scroll_behavior.dart
packages/flutter/lib/src/animation/scroll_behavior.dart
+16
-4
No files found.
packages/flutter/lib/src/animation/scroll_behavior.dart
View file @
461b1914
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:sky'
as
sky
;
import
'package:newton/newton.dart'
;
...
...
@@ -95,10 +96,21 @@ class UnboundedBehavior extends ExtentScrollBehavior {
}
Simulation
_createDefaultScrollSimulation
(
double
position
,
double
velocity
,
double
minScrollOffset
,
double
maxScrollOffset
)
{
double
velocityPerSecond
=
velocity
*
_kSecondsPerMillisecond
;
SpringDescription
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
170.0
,
ratio:
1.1
);
return
new
ScrollSimulation
(
position
,
velocityPerSecond
,
minScrollOffset
,
maxScrollOffset
,
spring
,
_kScrollDrag
);
double
startVelocity
=
velocity
*
_kSecondsPerMillisecond
;
// Assume that we're rendering at atleast 15 FPS. Stop when we're
// scrolling less than one logical pixel per frame. We're essentially
// normalizing by the devicePixelRatio so that the threshold has the
// same effect independent of the device's pixel density.
double
endVelocity
=
15.0
*
sky
.
view
.
devicePixelRatio
;
// Similar to endVelocity. Stop scrolling when we're this close to
// destiniation scroll offset.
double
endDistance
=
0.5
*
sky
.
view
.
devicePixelRatio
;
SpringDescription
spring
=
new
SpringDescription
.
withDampingRatio
(
mass:
1.0
,
springConstant:
170.0
,
ratio:
1.1
);
return
new
ScrollSimulation
(
position
,
startVelocity
,
endVelocity
,
endDistance
,
minScrollOffset
,
maxScrollOffset
,
spring
,
_kScrollDrag
);
}
/// A scroll behavior that lets the user scroll beyond the scroll bounds with some resistance
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment