Skip to content

Commit 31c1b00

Browse files
committed
fix #13
1 parent 0dfb912 commit 31c1b00

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ OverPack inherit Element; `component` `playScale` `onChange` `location` refer to
153153
| onStartBack | function | - | scroll up animate start (playScale[1]) callback; |
154154
| onCompleteBack | function | - | scroll up animate completed (playScale[0]) callback; |
155155

156-
> animation = [{},{}] 时为timeline;
156+
> animation = [{},{}] is timeline;
157157
158158
### Link
159159
| name | type | default | description |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-scroll-anim",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "scroll-anim anim component for react",
55
"keywords": [
66
"react",

src/ScrollParallax.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ScrollParallax extends React.Component {
2929
this.scrollTop = 0;
3030
this.defaultTweenData = [];
3131
this.defaultData = [];
32+
this.timeout = null;
3233
this.state = {};
3334
}
3435

@@ -40,7 +41,7 @@ class ScrollParallax extends React.Component {
4041
this.setDefaultData(this.props.animation || {});
4142

4243
// 第一次进入;
43-
setTimeout(() => {
44+
this.timeout = setTimeout(() => {
4445
this.timeline = new Timeline(this.dom, this.defaultTweenData);
4546
// 预注册;
4647
this.timeline.frame(0);
@@ -62,7 +63,12 @@ class ScrollParallax extends React.Component {
6263
}
6364

6465
componentWillUnmount() {
65-
EventListener.removeEventListener(this.eventType, this.scrollEventListener);
66+
if (!this.eventType && this.timeout) {
67+
clearTimeout(this.timeout);
68+
this.timeout = null;
69+
} else {
70+
EventListener.removeEventListener(this.eventType, this.scrollEventListener);
71+
}
6672
}
6773

6874
setDefaultData = _vars => {

0 commit comments

Comments
 (0)