-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPointer.jsx
More file actions
37 lines (31 loc) · 824 Bytes
/
Pointer.jsx
File metadata and controls
37 lines (31 loc) · 824 Bytes
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
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
class Pointer extends PureComponent {
static propTypes = {
length: PropTypes.number.isRequired,
index: PropTypes.number.isRequired,
changeIndex: PropTypes.func
}
render() {
console.info("Point render")
const {
length,
changeIndex,
index
} = this.props
let i = 0, items = [];
for (i; i < length; i++) {
if (i === index) {
items.push(<span onClick={changeIndex.bind(null, i)} key={i} className="pointer on"></span>);
} else {
items.push(<span onClick={changeIndex.bind(null, i)} key={i} className="pointer"></span>);
}
}
return (
<div className="viewer-image-pointer">
{items}
</div>
);
}
}
export default Pointer;