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
49b0843c
Commit
49b0843c
authored
Nov 18, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for repeating performances
Fixes #447
parent
4d0520bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
performance.dart
packages/flutter/lib/src/animation/performance.dart
+30
-1
No files found.
packages/flutter/lib/src/animation/performance.dart
View file @
49b0843c
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:ui'
show
VoidCallback
;
import
'dart:ui'
show
VoidCallback
,
lerpDouble
;
import
'package:newton/newton.dart'
;
import
'animated_value.dart'
;
import
'animated_value.dart'
;
import
'forces.dart'
;
import
'forces.dart'
;
...
@@ -146,6 +148,27 @@ class ReversePerformance extends PerformanceView {
...
@@ -146,6 +148,27 @@ class ReversePerformance extends PerformanceView {
}
}
}
}
class
_RepeatingSimulation
extends
Simulation
{
_RepeatingSimulation
(
this
.
min
,
this
.
max
,
Duration
period
)
:
_periodInSeconds
=
period
.
inMicroseconds
.
toDouble
()
/
Duration
.
MICROSECONDS_PER_SECOND
{
assert
(
_periodInSeconds
>
0.0
);
}
final
double
min
;
final
double
max
;
final
double
_periodInSeconds
;
double
x
(
double
timeInSeconds
)
{
assert
(
timeInSeconds
>=
0.0
);
final
double
t
=
(
timeInSeconds
/
_periodInSeconds
)
%
1.0
;
return
lerpDouble
(
min
,
max
,
t
);
}
double
dx
(
double
timeInSeconds
)
=>
1.0
;
bool
isDone
(
double
timeInSeconds
)
=>
false
;
}
/// A timeline that can be reversed and used to update [Animatable]s.
/// A timeline that can be reversed and used to update [Animatable]s.
///
///
...
@@ -249,6 +272,12 @@ class Performance extends PerformanceView {
...
@@ -249,6 +272,12 @@ class Performance extends PerformanceView {
return
_timeline
.
animateWith
(
force
.
release
(
progress
,
velocity
));
return
_timeline
.
animateWith
(
force
.
release
(
progress
,
velocity
));
}
}
Future
repeat
({
double
min:
0.0
,
double
max:
1.0
,
Duration
period
})
{
if
(
period
==
null
)
period
=
duration
;
return
_timeline
.
animateWith
(
new
_RepeatingSimulation
(
min
,
max
,
period
));
}
final
List
<
VoidCallback
>
_listeners
=
new
List
<
VoidCallback
>();
final
List
<
VoidCallback
>
_listeners
=
new
List
<
VoidCallback
>();
/// Calls the listener every time the progress of this performance changes
/// Calls the listener every time the progress of this performance changes
...
...
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