Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
5bad6148
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5bad6148
编写于
8月 14, 2015
作者:
M
mpcomplete
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #597 from mpcomplete/value.animation
Add a ValueAnimation helper class for AnimationPerfomance.
上级
ed7b8d3c
e58a2bdd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
17 deletion
+30
-17
examples/widgets/ensure_visible.dart
examples/widgets/ensure_visible.dart
+2
-2
sky/packages/sky/lib/animation/animation_performance.dart
sky/packages/sky/lib/animation/animation_performance.dart
+17
-2
sky/packages/sky/lib/widgets/scrollable.dart
sky/packages/sky/lib/widgets/scrollable.dart
+6
-8
sky/packages/sky/lib/widgets/tabs.dart
sky/packages/sky/lib/widgets/tabs.dart
+5
-5
未找到文件。
examples/widgets/ensure_visible.dart
浏览文件 @
5bad6148
...
...
@@ -38,7 +38,7 @@ class EnsureVisibleApp extends App {
List
<
CardModel
>
cardModels
;
BlockViewportLayoutState
layoutState
=
new
BlockViewportLayoutState
();
ScrollListener
scrollListener
;
AnimationPerformance
scrollAnimation
;
ValueAnimation
<
double
>
scrollAnimation
;
void
initState
()
{
List
<
double
>
cardHeights
=
<
double
>[
...
...
@@ -51,7 +51,7 @@ class EnsureVisibleApp extends App {
return
new
CardModel
(
i
,
cardHeights
[
i
],
color
);
});
scrollAnimation
=
new
AnimationPerformance
()
scrollAnimation
=
new
ValueAnimation
<
double
>
()
..
duration
=
const
Duration
(
milliseconds:
200
)
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
...
...
sky/packages/sky/lib/animation/animation_performance.dart
浏览文件 @
5bad6148
...
...
@@ -26,13 +26,17 @@ enum AnimationStatus {
// manipulating |progress|, or |fling| the timeline causing a physics-based
// simulation to take over the progression.
class
AnimationPerformance
{
AnimationPerformance
({
this
.
variable
,
this
.
duration
})
{
AnimationPerformance
({
AnimatedVariable
variable
,
this
.
duration
})
:
_variable
=
variable
{
_timeline
=
new
Timeline
(
_tick
);
}
AnimatedVariable
variable
;
AnimatedVariable
_
variable
;
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.
Timeline
_timeline
;
Timeline
get
timeline
=>
_timeline
;
...
...
@@ -179,3 +183,14 @@ class AnimationPerformance {
_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
;
}
sky/packages/sky/lib/widgets/scrollable.dart
浏览文件 @
5bad6148
...
...
@@ -7,7 +7,6 @@ import 'dart:sky' as sky;
import
'package:newton/newton.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/scroll_behavior.dart'
;
import
'package:sky/rendering/box.dart'
;
...
...
@@ -44,7 +43,7 @@ abstract class Scrollable extends StatefulComponent {
ScrollDirection
scrollDirection
;
AnimatedSimulation
_toEndAnimation
;
// See _startToEndAnimation()
AnimationPerformance
_toOffsetAnimation
;
// Started by scrollTo()
ValueAnimation
<
double
>
_toOffsetAnimation
;
// Started by scrollTo()
void
initState
()
{
_toEndAnimation
=
new
AnimatedSimulation
(
_tickScrollOffset
);
...
...
@@ -86,11 +85,11 @@ abstract class Scrollable extends StatefulComponent {
);
}
void
_startToOffsetAnimation
(
double
newScrollOffset
,
AnimationPerformance
animation
)
{
void
_startToOffsetAnimation
(
double
newScrollOffset
,
ValueAnimation
<
double
>
animation
)
{
_stopToEndAnimation
();
_stopToOffsetAnimation
();
(
animation
.
variable
as
AnimatedValue
<
double
>)
animation
.
variable
..
begin
=
scrollOffset
..
end
=
newScrollOffset
;
...
...
@@ -102,8 +101,7 @@ abstract class Scrollable extends StatefulComponent {
}
void
_updateToOffsetAnimation
()
{
AnimatedValue
<
double
>
offset
=
_toOffsetAnimation
.
variable
;
scrollTo
(
offset
.
value
);
scrollTo
(
_toOffsetAnimation
.
value
);
}
void
_updateToOffsetAnimationStatus
(
AnimationStatus
status
)
{
...
...
@@ -139,7 +137,7 @@ abstract class Scrollable extends StatefulComponent {
super
.
didUnmount
();
}
bool
scrollTo
(
double
newScrollOffset
,
{
AnimationPerformance
animation
})
{
bool
scrollTo
(
double
newScrollOffset
,
{
ValueAnimation
<
double
>
animation
})
{
if
(
newScrollOffset
==
_scrollOffset
)
return
false
;
...
...
@@ -233,7 +231,7 @@ Scrollable findScrollableAncestor({ Widget target }) {
return
ancestor
;
}
bool
ensureWidgetIsVisible
(
Widget
target
,
{
AnimationPerformance
animation
})
{
bool
ensureWidgetIsVisible
(
Widget
target
,
{
ValueAnimation
<
double
>
animation
})
{
assert
(
target
.
mounted
);
assert
(
target
.
root
is
RenderBox
);
...
...
sky/packages/sky/lib/widgets/tabs.dart
浏览文件 @
5bad6148
...
...
@@ -406,15 +406,15 @@ class TabBar extends Scrollable {
Size
_tabBarSize
;
List
<
double
>
_tabWidths
;
AnimationPerformance
_indicatorAnimation
;
AnimationPerformance
_scrollAnimation
;
ValueAnimation
<
Rect
>
_indicatorAnimation
;
ValueAnimation
<
double
>
_scrollAnimation
;
void
initState
()
{
super
.
initState
();
_indicatorAnimation
=
new
AnimationPerformance
()
_indicatorAnimation
=
new
ValueAnimation
<
Rect
>
()
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedRect
(
null
,
curve:
ease
);
_scrollAnimation
=
new
AnimationPerformance
()
_scrollAnimation
=
new
ValueAnimation
<
double
>
()
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
curve:
ease
);
}
...
...
@@ -430,7 +430,7 @@ class TabBar extends Scrollable {
scrollBehavior
.
isScrollable
=
source
.
isScrollable
;
}
AnimatedRect
get
_indicatorRect
=>
_indicatorAnimation
.
variable
as
AnimatedRect
;
AnimatedRect
get
_indicatorRect
=>
_indicatorAnimation
.
variable
;
void
_startIndicatorAnimation
(
int
fromTabIndex
,
int
toTabIndex
)
{
_indicatorRect
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录