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
203e6fd7
Commit
203e6fd7
authored
Oct 03, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Ticker start ticking at zero Duration
The only client wants a zero-based duration.
parent
db191e96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
animated_simulation.dart
packages/flutter/lib/src/animation/animated_simulation.dart
+13
-13
No files found.
packages/flutter/lib/src/animation/animated_simulation.dart
View file @
203e6fd7
...
...
@@ -7,7 +7,7 @@ import 'dart:async';
import
'package:newton/newton.dart'
;
import
'package:sky/src/animation/scheduler.dart'
;
typedef
_TickerCallback
(
Duration
timeStamp
);
typedef
_TickerCallback
(
Duration
elapsed
);
/// Calls its callback once per animation frame
class
Ticker
{
...
...
@@ -18,12 +18,14 @@ class Ticker {
Completer
_completer
;
int
_animationId
;
Duration
_startTime
;
/// Start calling onTick once per animation frame
///
/// The returned future resolves once the ticker stops ticking.
Future
start
()
{
assert
(!
isTicking
);
assert
(
_startTime
==
null
);
_completer
=
new
Completer
();
_scheduleTick
();
return
_completer
.
future
;
...
...
@@ -36,6 +38,8 @@ class Ticker {
if
(!
isTicking
)
return
;
_startTime
=
null
;
if
(
_animationId
!=
null
)
{
scheduler
.
cancelAnimationFrame
(
_animationId
);
_animationId
=
null
;
...
...
@@ -58,7 +62,10 @@ class Ticker {
assert
(
_animationId
!=
null
);
_animationId
=
null
;
_onTick
(
timeStamp
);
if
(
_startTime
==
null
)
_startTime
=
timeStamp
;
_onTick
(
timeStamp
-
_startTime
);
// The onTick callback may have scheduled another tick already.
if
(
isTicking
&&
_animationId
==
null
)
...
...
@@ -83,7 +90,6 @@ class AnimatedSimulation {
Ticker
_ticker
;
Simulation
_simulation
;
Duration
_startTime
;
double
_value
=
0.0
;
/// The current value of the simulation
...
...
@@ -101,7 +107,6 @@ class AnimatedSimulation {
assert
(
simulation
!=
null
);
assert
(!
_ticker
.
isTicking
);
_simulation
=
simulation
;
_startTime
=
null
;
_value
=
simulation
.
x
(
0.0
);
return
_ticker
.
start
();
}
...
...
@@ -109,23 +114,18 @@ class AnimatedSimulation {
/// Stop ticking the current simulation
void
stop
()
{
_simulation
=
null
;
_startTime
=
null
;
_ticker
.
stop
();
}
/// Whether this object is currently ticking a simulation
bool
get
isAnimating
=>
_ticker
.
isTicking
;
void
_tick
(
Duration
timeStamp
)
{
if
(
_startTime
==
null
)
_startTime
=
timeStamp
;
void
_tick
(
Duration
elapsed
)
{
double
timeInMicroseconds
=
(
timeStamp
-
_startTime
).
inMicroseconds
.
toDouble
();
double
timeInSeconds
=
timeInMicroseconds
/
Duration
.
MICROSECONDS_PER_SECOND
;
_value
=
_simulation
.
x
(
timeInSeconds
);
final
bool
isLastTick
=
_simulation
.
isDone
(
timeInSeconds
);
double
elapsedInSeconds
=
elapsed
.
inMicroseconds
.
toDouble
()
/
Duration
.
MICROSECONDS_PER_SECOND
;
_value
=
_simulation
.
x
(
elapsedInSeconds
);
if
(
isLastTick
)
if
(
_simulation
.
isDone
(
elapsedInSeconds
)
)
stop
();
_onTick
(
_value
);
...
...
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