Skip to content

Commit 5cb08f0

Browse files
authored
Merge pull request crazycodeboy#20 from xiaozhicheng/master
D10:优化切换动画卡顿的问题
2 parents 3230e40 + 7b8fd00 commit 5cb08f0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

React Native 每日一学/Readme.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
7. [D7:解构赋值(Destructuring assignment)(2016-8-26)](#d7解构赋值destructuring-assignment2016-8-26)
1616
8. [D8:React-Native 原生模块调用(iOS) (2016-8-29)](#d8react-native-原生模块调用ios-2016-8-29)
1717
9. [D9:动态属性名&字符串模板(2016-8-30)](#d9动态属性名字符串模板2016-8-30)
18+
10. [D10:优化切换动画卡顿的问题(2016-8-31)](#d10优化切换动画卡顿的问题2016-8-31)
1819
```
1920
模板:
2021
D1:标题 (日期)
@@ -26,7 +27,20 @@ D1:标题 (日期)
2627
内容
2728
另外:记得在列表中添加链接
2829
```
29-
30+
D10:优化切换动画卡顿的问题(2016-8-31)
31+
------
32+
使用API InteractionManager,它的作用就是可以使本来JS的一些操作在动画完成之后执行,这样就可确保动画的流程性。当然这是在延迟执行为代价上来获得帧数的提高。
33+
```javascript
34+
InteractionManager.runAfterInteractions(()=>{
35+
//...耗时较长的同步任务...
36+
//更新state也需要时间
37+
this.setState({
38+
...
39+
})
40+
//获取某些数据,需要长时间等待
41+
this.fetchData(arguements)
42+
})
43+
```
3044
D9:动态属性名&字符串模板(2016-8-30)
3145
------
3246
在 ES6+ 中,我们不仅可以在对象字面量属性的定义中使用表达式,还有使用使用字符串模板:

0 commit comments

Comments
 (0)