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
7b0e7ee3
Commit
7b0e7ee3
authored
Feb 22, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some trivial animation library cleanup.
parent
347ee25a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
46 deletions
+46
-46
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+43
-43
animations.dart
packages/flutter/lib/src/animation/animations.dart
+2
-2
tween.dart
packages/flutter/lib/src/animation/tween.dart
+1
-1
No files found.
packages/flutter/lib/src/animation/animation_controller.dart
View file @
7b0e7ee3
...
...
@@ -48,7 +48,7 @@ class AnimationController extends Animation<double>
/// * debugLabel is a string to help identify this animation during debugging (used by toString).
///
/// This constructor is most useful for animations that will be driven using a
/// physics simulation, especially when the physics simulation as no
/// physics simulation, especially when the physics simulation
h
as no
/// pre-determined bounds.
AnimationController
.
unbounded
({
double
value:
0.0
,
...
...
@@ -128,48 +128,6 @@ class AnimationController extends Animation<double>
return
animateTo
(
_direction
==
AnimationDirection
.
forward
?
upperBound
:
lowerBound
);
}
/// Stops running this animation.
void
stop
()
{
_simulation
=
null
;
_ticker
.
stop
();
}
/// Stops running this animation.
void
dispose
()
{
stop
();
}
/// Flings the timeline with an optional force (defaults to a critically
/// damped spring) and initial velocity. If velocity is positive, the
/// animation will complete, otherwise it will dismiss.
Future
fling
({
double
velocity:
1.0
,
Force
force
})
{
force
??=
kDefaultSpringForce
;
_direction
=
velocity
<
0.0
?
AnimationDirection
.
reverse
:
AnimationDirection
.
forward
;
return
animateWith
(
force
.
release
(
value
,
velocity
));
}
/// Starts running this animation in the forward direction, and
/// restarts the animation when it completes.
Future
repeat
({
double
min:
0.0
,
double
max:
1.0
,
Duration
period
})
{
period
??=
duration
;
return
animateWith
(
new
_RepeatingSimulation
(
min
,
max
,
period
));
}
/// Drives the animation according to the given simulation.
Future
animateWith
(
Simulation
simulation
)
{
stop
();
return
_startSimulation
(
simulation
);
}
AnimationStatus
_lastStatus
=
AnimationStatus
.
dismissed
;
void
_checkStatusChanged
()
{
AnimationStatus
newStatus
=
status
;
AnimationStatus
oldStatus
=
_lastStatus
;
_lastStatus
=
newStatus
;
if
(
oldStatus
!=
newStatus
)
notifyStatusListeners
(
newStatus
);
}
/// Drives the animation from its current value to target.
Future
animateTo
(
double
target
,
{
Duration
duration
,
Curve
curve:
Curves
.
linear
})
{
Duration
simulationDuration
=
duration
;
...
...
@@ -190,6 +148,28 @@ class AnimationController extends Animation<double>
return
_startSimulation
(
new
_TweenSimulation
(
_value
,
target
,
simulationDuration
,
curve
));
}
/// Starts running this animation in the forward direction, and
/// restarts the animation when it completes.
Future
repeat
({
double
min:
0.0
,
double
max:
1.0
,
Duration
period
})
{
period
??=
duration
;
return
animateWith
(
new
_RepeatingSimulation
(
min
,
max
,
period
));
}
/// Flings the timeline with an optional force (defaults to a critically
/// damped spring) and initial velocity. If velocity is positive, the
/// animation will complete, otherwise it will dismiss.
Future
fling
({
double
velocity:
1.0
,
Force
force
})
{
force
??=
kDefaultSpringForce
;
_direction
=
velocity
<
0.0
?
AnimationDirection
.
reverse
:
AnimationDirection
.
forward
;
return
animateWith
(
force
.
release
(
value
,
velocity
));
}
/// Drives the animation according to the given simulation.
Future
animateWith
(
Simulation
simulation
)
{
stop
();
return
_startSimulation
(
simulation
);
}
Future
_startSimulation
(
Simulation
simulation
)
{
assert
(
simulation
!=
null
);
assert
(!
isAnimating
);
...
...
@@ -198,6 +178,26 @@ class AnimationController extends Animation<double>
return
_ticker
.
start
();
}
/// Stops running this animation.
void
stop
()
{
_simulation
=
null
;
_ticker
.
stop
();
}
/// Stops running this animation.
void
dispose
()
{
stop
();
}
AnimationStatus
_lastStatus
=
AnimationStatus
.
dismissed
;
void
_checkStatusChanged
()
{
AnimationStatus
newStatus
=
status
;
AnimationStatus
oldStatus
=
_lastStatus
;
_lastStatus
=
newStatus
;
if
(
oldStatus
!=
newStatus
)
notifyStatusListeners
(
newStatus
);
}
void
_tick
(
Duration
elapsed
)
{
double
elapsedInSeconds
=
elapsed
.
inMicroseconds
.
toDouble
()
/
Duration
.
MICROSECONDS_PER_SECOND
;
_value
=
_simulation
.
x
(
elapsedInSeconds
);
...
...
packages/flutter/lib/src/animation/animations.dart
View file @
7b0e7ee3
...
...
@@ -47,10 +47,10 @@ class _AlwaysDismissedAnimation extends Animation<double> {
const
Animation
<
double
>
kAlwaysDismissedAnimation
=
const
_AlwaysDismissedAnimation
();
/// An animation that is always stopped at a given value.
class
AlwaysStoppedAnimation
extends
Animation
<
double
>
{
class
AlwaysStoppedAnimation
<
T
>
extends
Animation
<
T
>
{
const
AlwaysStoppedAnimation
(
this
.
value
);
final
double
value
;
final
T
value
;
void
addListener
(
VoidCallback
listener
)
{
}
void
removeListener
(
VoidCallback
listener
)
{
}
...
...
packages/flutter/lib/src/animation/tween.dart
View file @
7b0e7ee3
...
...
@@ -47,7 +47,7 @@ class _ChainedEvaluation<T> extends Animatable<T> {
T
evaluate
(
Animation
<
double
>
animation
)
{
double
value
=
_parent
.
evaluate
(
animation
);
return
_evaluatable
.
evaluate
(
new
AlwaysStoppedAnimation
(
value
));
return
_evaluatable
.
evaluate
(
new
AlwaysStoppedAnimation
<
double
>
(
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