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
0c05c97e
Commit
0c05c97e
authored
Aug 14, 2015
by
mpcomplete
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #597 from mpcomplete/value.animation
Add a ValueAnimation helper class for AnimationPerfomance.
parents
87df0e5b
82d84c76
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
17 deletions
+30
-17
ensure_visible.dart
examples/widgets/ensure_visible.dart
+2
-2
animation_performance.dart
packages/flutter/lib/animation/animation_performance.dart
+17
-2
scrollable.dart
packages/flutter/lib/widgets/scrollable.dart
+6
-8
tabs.dart
packages/flutter/lib/widgets/tabs.dart
+5
-5
No files found.
examples/widgets/ensure_visible.dart
View file @
0c05c97e
...
@@ -38,7 +38,7 @@ class EnsureVisibleApp extends App {
...
@@ -38,7 +38,7 @@ class EnsureVisibleApp extends App {
List
<
CardModel
>
cardModels
;
List
<
CardModel
>
cardModels
;
BlockViewportLayoutState
layoutState
=
new
BlockViewportLayoutState
();
BlockViewportLayoutState
layoutState
=
new
BlockViewportLayoutState
();
ScrollListener
scrollListener
;
ScrollListener
scrollListener
;
AnimationPerformance
scrollAnimation
;
ValueAnimation
<
double
>
scrollAnimation
;
void
initState
()
{
void
initState
()
{
List
<
double
>
cardHeights
=
<
double
>[
List
<
double
>
cardHeights
=
<
double
>[
...
@@ -51,7 +51,7 @@ class EnsureVisibleApp extends App {
...
@@ -51,7 +51,7 @@ class EnsureVisibleApp extends App {
return
new
CardModel
(
i
,
cardHeights
[
i
],
color
);
return
new
CardModel
(
i
,
cardHeights
[
i
],
color
);
});
});
scrollAnimation
=
new
AnimationPerformance
()
scrollAnimation
=
new
ValueAnimation
<
double
>
()
..
duration
=
const
Duration
(
milliseconds:
200
)
..
duration
=
const
Duration
(
milliseconds:
200
)
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
...
...
packages/flutter/lib/animation/animation_performance.dart
View file @
0c05c97e
...
@@ -26,13 +26,17 @@ enum AnimationStatus {
...
@@ -26,13 +26,17 @@ enum AnimationStatus {
// manipulating |progress|, or |fling| the timeline causing a physics-based
// manipulating |progress|, or |fling| the timeline causing a physics-based
// simulation to take over the progression.
// simulation to take over the progression.
class
AnimationPerformance
{
class
AnimationPerformance
{
AnimationPerformance
({
this
.
variable
,
this
.
duration
})
{
AnimationPerformance
({
AnimatedVariable
variable
,
this
.
duration
})
:
_variable
=
variable
{
_timeline
=
new
Timeline
(
_tick
);
_timeline
=
new
Timeline
(
_tick
);
}
}
AnimatedVariable
variable
;
AnimatedVariable
_
variable
;
Duration
duration
;
Duration
duration
;
AnimatedVariable
get
variable
=>
_variable
;
void
set
variable
(
AnimatedVariable
v
)
{
_variable
=
v
;
}
// Advances from 0 to 1. On each tick, we'll update our variable's values.
// Advances from 0 to 1. On each tick, we'll update our variable's values.
Timeline
_timeline
;
Timeline
_timeline
;
Timeline
get
timeline
=>
_timeline
;
Timeline
get
timeline
=>
_timeline
;
...
@@ -179,3 +183,14 @@ class AnimationPerformance {
...
@@ -179,3 +183,14 @@ class AnimationPerformance {
_checkStatusChanged
();
_checkStatusChanged
();
}
}
}
}
// Simple helper class for an animation with a single value.
class
ValueAnimation
<
T
>
extends
AnimationPerformance
{
ValueAnimation
({
AnimatedValue
<
T
>
variable
,
Duration
duration
})
:
super
(
variable:
variable
,
duration:
duration
);
AnimatedValue
<
T
>
get
variable
=>
_variable
as
AnimatedValue
<
T
>;
void
set
variable
(
AnimatedValue
<
T
>
v
)
{
_variable
=
v
;
}
T
get
value
=>
variable
.
value
;
}
packages/flutter/lib/widgets/scrollable.dart
View file @
0c05c97e
...
@@ -7,7 +7,6 @@ import 'dart:sky' as sky;
...
@@ -7,7 +7,6 @@ import 'dart:sky' as sky;
import
'package:newton/newton.dart'
;
import
'package:newton/newton.dart'
;
import
'package:sky/animation/animated_simulation.dart'
;
import
'package:sky/animation/animated_simulation.dart'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/scroll_behavior.dart'
;
import
'package:sky/animation/scroll_behavior.dart'
;
import
'package:sky/rendering/box.dart'
;
import
'package:sky/rendering/box.dart'
;
...
@@ -44,7 +43,7 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -44,7 +43,7 @@ abstract class Scrollable extends StatefulComponent {
ScrollDirection
scrollDirection
;
ScrollDirection
scrollDirection
;
AnimatedSimulation
_toEndAnimation
;
// See _startToEndAnimation()
AnimatedSimulation
_toEndAnimation
;
// See _startToEndAnimation()
AnimationPerformance
_toOffsetAnimation
;
// Started by scrollTo()
ValueAnimation
<
double
>
_toOffsetAnimation
;
// Started by scrollTo()
void
initState
()
{
void
initState
()
{
_toEndAnimation
=
new
AnimatedSimulation
(
_tickScrollOffset
);
_toEndAnimation
=
new
AnimatedSimulation
(
_tickScrollOffset
);
...
@@ -86,11 +85,11 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -86,11 +85,11 @@ abstract class Scrollable extends StatefulComponent {
);
);
}
}
void
_startToOffsetAnimation
(
double
newScrollOffset
,
AnimationPerformance
animation
)
{
void
_startToOffsetAnimation
(
double
newScrollOffset
,
ValueAnimation
<
double
>
animation
)
{
_stopToEndAnimation
();
_stopToEndAnimation
();
_stopToOffsetAnimation
();
_stopToOffsetAnimation
();
(
animation
.
variable
as
AnimatedValue
<
double
>)
animation
.
variable
..
begin
=
scrollOffset
..
begin
=
scrollOffset
..
end
=
newScrollOffset
;
..
end
=
newScrollOffset
;
...
@@ -102,8 +101,7 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -102,8 +101,7 @@ abstract class Scrollable extends StatefulComponent {
}
}
void
_updateToOffsetAnimation
()
{
void
_updateToOffsetAnimation
()
{
AnimatedValue
<
double
>
offset
=
_toOffsetAnimation
.
variable
;
scrollTo
(
_toOffsetAnimation
.
value
);
scrollTo
(
offset
.
value
);
}
}
void
_updateToOffsetAnimationStatus
(
AnimationStatus
status
)
{
void
_updateToOffsetAnimationStatus
(
AnimationStatus
status
)
{
...
@@ -139,7 +137,7 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -139,7 +137,7 @@ abstract class Scrollable extends StatefulComponent {
super
.
didUnmount
();
super
.
didUnmount
();
}
}
bool
scrollTo
(
double
newScrollOffset
,
{
AnimationPerformance
animation
})
{
bool
scrollTo
(
double
newScrollOffset
,
{
ValueAnimation
<
double
>
animation
})
{
if
(
newScrollOffset
==
_scrollOffset
)
if
(
newScrollOffset
==
_scrollOffset
)
return
false
;
return
false
;
...
@@ -233,7 +231,7 @@ Scrollable findScrollableAncestor({ Widget target }) {
...
@@ -233,7 +231,7 @@ Scrollable findScrollableAncestor({ Widget target }) {
return
ancestor
;
return
ancestor
;
}
}
bool
ensureWidgetIsVisible
(
Widget
target
,
{
AnimationPerformance
animation
})
{
bool
ensureWidgetIsVisible
(
Widget
target
,
{
ValueAnimation
<
double
>
animation
})
{
assert
(
target
.
mounted
);
assert
(
target
.
mounted
);
assert
(
target
.
root
is
RenderBox
);
assert
(
target
.
root
is
RenderBox
);
...
...
packages/flutter/lib/widgets/tabs.dart
View file @
0c05c97e
...
@@ -406,15 +406,15 @@ class TabBar extends Scrollable {
...
@@ -406,15 +406,15 @@ class TabBar extends Scrollable {
Size
_tabBarSize
;
Size
_tabBarSize
;
List
<
double
>
_tabWidths
;
List
<
double
>
_tabWidths
;
AnimationPerformance
_indicatorAnimation
;
ValueAnimation
<
Rect
>
_indicatorAnimation
;
AnimationPerformance
_scrollAnimation
;
ValueAnimation
<
double
>
_scrollAnimation
;
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_indicatorAnimation
=
new
AnimationPerformance
()
_indicatorAnimation
=
new
ValueAnimation
<
Rect
>
()
..
duration
=
_kTabBarScroll
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedRect
(
null
,
curve:
ease
);
..
variable
=
new
AnimatedRect
(
null
,
curve:
ease
);
_scrollAnimation
=
new
AnimationPerformance
()
_scrollAnimation
=
new
ValueAnimation
<
double
>
()
..
duration
=
_kTabBarScroll
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
}
}
...
@@ -430,7 +430,7 @@ class TabBar extends Scrollable {
...
@@ -430,7 +430,7 @@ class TabBar extends Scrollable {
scrollBehavior
.
isScrollable
=
source
.
isScrollable
;
scrollBehavior
.
isScrollable
=
source
.
isScrollable
;
}
}
AnimatedRect
get
_indicatorRect
=>
_indicatorAnimation
.
variable
as
AnimatedRect
;
AnimatedRect
get
_indicatorRect
=>
_indicatorAnimation
.
variable
;
void
_startIndicatorAnimation
(
int
fromTabIndex
,
int
toTabIndex
)
{
void
_startIndicatorAnimation
(
int
fromTabIndex
,
int
toTabIndex
)
{
_indicatorRect
_indicatorRect
...
...
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