Skip to content

Commit 665a918

Browse files
committed
add element location
1 parent 61b9273 commit 665a918

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ ScrollAnim.scrollScreen.unMount();
120120
| id | string | null | need to location the id,parallax the `location` or link the `to`, need to use |
121121
| playScale | number / array | `0.5` | percentage of screen to start play, screen center is 0.5, if replay is true : [bottomEnter, topLeave], topLeave >= bottomEnter |
122122
| onChange | func | null | change callback({ mode, scrollName }); mode: `enter` or `leave` |
123+
| location | string | null | v0.6.0 above have,location, the parent id; |
123124

124125
> Note: if the element is not the above component, you need to location this element; please use the `Element`
125126
126127
### OverPack
127128

128-
OverPack inherit Element; `component` `playScale` `onChange` refer to `Element`;
129+
OverPack inherit Element; `component` `playScale` `onChange` `location` refer to `Element`;
129130

130131
| name | type | default | description |
131132
|-----------|----------------|---------|----------------|
@@ -137,7 +138,7 @@ OverPack inherit Element; `component` `playScale` `onChange` refer to `Element`
137138
| name | type | default | description |
138139
|-----------|----------------|---------|----------------|
139140
| animation | object / array | `null` | animation data |
140-
| location | string | `null` | location, `Element` the id, only scroll name |
141+
| location | string | `null` | location, the parent id |
141142
| always | boolean | `true` | - |
142143
| component | string | `div` | - |
143144

examples/scrollScreen.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,25 @@ class Demo extends React.Component {
9090
</div>
9191
</QueueAnim>
9292
</Element>
93-
<ScrollOverPack
94-
id="page1"
95-
className="page1"
96-
playScale={1}
97-
replay
98-
hideProps={{ 0: { reverse: true } }}
99-
>
100-
<TweenOne className="tween-one" key="0" animation={{ opacity: 1 }}>
101-
每次进入都启动播放
102-
</TweenOne>
103-
<QueueAnim key="1" style={{ height: 100 }}>
104-
<div key="0" className="demo"></div>
105-
<div key="1" className="demo"></div>
106-
<div key="2" className="demo"></div>
107-
<div key="3" className="demo"></div>
108-
</QueueAnim>
109-
</ScrollOverPack>
93+
<div id="page1">
94+
<ScrollOverPack
95+
className="page1"
96+
playScale={1}
97+
replay
98+
hideProps={{ 0: { reverse: true } }}
99+
location="page1"
100+
>
101+
<TweenOne className="tween-one" key="0" animation={{ opacity: 1 }}>
102+
每次进入都启动播放
103+
</TweenOne>
104+
<QueueAnim key="1" style={{ height: 100 }}>
105+
<div key="0" className="demo"></div>
106+
<div key="1" className="demo"></div>
107+
<div key="2" className="demo"></div>
108+
<div key="3" className="demo"></div>
109+
</QueueAnim>
110+
</ScrollOverPack>
111+
</div>
110112

111113
<ScrollOverPack
112114
className="pack-page page2"

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.5.3",
3+
"version": "0.6.0",
44
"description": "scroll-anim anim component for react",
55
"keywords": [
66
"react",

src/ScrollElement.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const noop = () => {
99
class ScrollElement extends React.Component {
1010
componentDidMount() {
1111
this.dom = ReactDOM.findDOMNode(this);
12-
if (this.props.id) {
12+
if (this.props.location) {
13+
mapped.register(this.props.location, document.getElementById(this.props.location));
14+
} else if (this.props.id) {
1315
mapped.register(this.props.id, this.dom);
1416
}
1517
const date = Date.now();
@@ -57,7 +59,7 @@ class ScrollElement extends React.Component {
5759

5860
render() {
5961
const { ...props } = this.props;
60-
['component', 'playScale'].forEach(key => delete props[key]);
62+
['component', 'playScale', 'location'].forEach(key => delete props[key]);
6163
return React.createElement(this.props.component, { ...props });
6264
}
6365
}
@@ -67,6 +69,7 @@ ScrollElement.propTypes = {
6769
playScale: React.PropTypes.any,
6870
id: React.PropTypes.string,
6971
onChange: React.PropTypes.func,
72+
location: React.PropTypes.string,
7073
};
7174

7275
ScrollElement.defaultProps = {

src/ScrollOverPack.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ScrollOverPack extends ScrollElement {
5252
'always',
5353
'scrollEvent',
5454
'hideProps',
55+
'location',
5556
].forEach(key => delete placeholderProps[key]);
5657
let childToRender;
5758
if (!this.oneEnter && !this.state.show) {

0 commit comments

Comments
 (0)