-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathComponents.js
64 lines (56 loc) · 1.66 KB
/
Components.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// @flow
import React from 'react';
import styled from 'styled-components';
import { Controller, Scene } from 'react-scrollmagic';
const ComponentsStyled = styled.div`
.section {
height: 70vh;
}
`;
const StyledDiv = styled.div`
background-color: red;
`;
const Stateless = ({children}) => <div id="stateless">{children}</div>;
const StatelessFragment = () => <React.Fragment><div id="statelessFragment">StatelessFragment Component</div></React.Fragment>;
const StatelessRef = React.forwardRef((props, ref) => (
<div ref={ref}>StatelessRef Component</div>
));
class Stateful extends React.Component {
render() {
return (
<div id="stateful">Stateful Component</div>
);
}
}
const Components = () => (
<ComponentsStyled>
<div className="section" />
<Controller>
<Scene duration={600} pin={true}>
<div>HTML tag</div>
</Scene>
<Scene duration={600} pin={true}>
<StatelessRef />
</Scene>
<Scene duration={600} pin={true}>
<StyledDiv>Styled Component</StyledDiv>
</Scene>
<Scene duration={600} pin="#stateless" triggerElement="#stateless">
<Stateless>Stateless Component</Stateless>
</Scene>
<Scene duration={600} pin={true}>
<div>
<Stateless>Stateless Component wrapped</Stateless>
</div>
</Scene>
<Scene duration={600} pin="#statelessFragment" triggerElement="#statelessFragment">
<StatelessFragment />
</Scene>
<Scene duration={600} pin="#stateful" triggerElement="#stateful">
<Stateful />
</Scene>
</Controller>
<div className="section" />
</ComponentsStyled>
);
export default Components;