-
Notifications
You must be signed in to change notification settings - Fork 627
/
Arrow.js
52 lines (48 loc) 路 1.07 KB
/
Arrow.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
import {createElement, Component} from 'rax';
import Image from 'rax-image';
import StyleSheet from 'universal-stylesheet';
export default class Arrow extends Component {
constructor(props) {
super(props);
const {style = arrowStyle.arrowIcon, containerWidth} = this.props;
const {width} = style;
this.position = {
top: {
top: - width,
transform: 'rotateX(180deg)'
},
bottom: {
bottom: - width
},
left: {
left: 15
},
middle: {
left: containerWidth / 2,
marginLeft: - (width / 2)
},
right: {
right: 15
}
};
}
render() {
const {
source,
arrowPosition = {x: 'middle', y: 'bottom'},
style = arrowStyle.arrowIcon
} = this.props;
const {x, y} = arrowPosition;
const positionStyle = [this.position[x], this.position[y]];
return (
<Image source={source} style={[style, positionStyle]} />
);
}
}
const arrowStyle = StyleSheet.create({
arrowIcon: {
width: 18,
height: 18,
position: 'absolute'
}
});