/
index.js
50 lines (43 loc) 路 1.61 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react'
import ReactDOM from 'react-dom'
import Parallax from '../index'
class App extends React.Component {
render() {
const styles = {
fontFamily: 'Menlo-Regular, Menlo, monospace',
fontSize: 14,
lineHeight: '10px',
color: 'white',
display: 'flex', alignItems: 'center', justifyContent: 'center'
}
return (
<Parallax ref="parallax" pages={3}>
<Parallax.Layer offset={0} speed={1} style={{ backgroundColor: '#243B4A' }} />
<Parallax.Layer offset={1} speed={1} style={{ backgroundColor: '#805E73' }} />
<Parallax.Layer offset={2} speed={1} style={{ backgroundColor: '#87BCDE' }} />
<Parallax.Layer
offset={0}
speed={0.5}
style={styles}
onClick={() => this.refs.parallax.scrollTo(1)}>
Click!
</Parallax.Layer>
<Parallax.Layer
offset={1}
speed={-0.1}
style={styles}
onClick={() => this.refs.parallax.scrollTo(2)}>
Another page ...
</Parallax.Layer>
<Parallax.Layer
offset={2}
speed={0.5}
style={styles}
onClick={() => this.refs.parallax.scrollTo(0)}>
The end.
</Parallax.Layer>
</Parallax>
)
}
}
ReactDOM.render(<App />, document.querySelector('#root'))