| 4 | import utils from '../utils/utils.js'; |
| 5 | |
| 6 | class Hand extends Component { |
| 7 | static propTypes = { |
| 8 | angle: PropTypes.number, |
| 9 | className: PropTypes.string, |
| 10 | length: PropTypes.number, |
| 11 | onMove: PropTypes.func, |
| 12 | onMoved: PropTypes.func, |
| 13 | origin: PropTypes.object, |
| 14 | step: PropTypes.number, |
| 15 | theme: PropTypes.shape({ |
| 16 | hand: PropTypes.string, |
| 17 | knob: PropTypes.string |
| 18 | }) |
| 19 | }; |
| 20 | |
| 21 | static defaultProps = { |
| 22 | className: '', |
| 23 | angle: 0, |
| 24 | length: 0, |
| 25 | origin: {} |
| 26 | }; |
| 27 | |
| 28 | state = { |
| 29 | knobWidth: 0 |
| 30 | }; |
| 31 | |
| 32 | componentDidMount () { |
| 33 | setTimeout(() => { |
| 34 | this.setState({knobWidth: this.refs.knob.offsetWidth}); |
| 35 | }); |
| 36 | } |
| 37 | |
| 38 | componentWillUnmount () { |
| 39 | events.removeEventsFromDocument(this.getMouseEventMap()); |
| 40 | events.removeEventsFromDocument(this.getTouchEventMap()); |
| 41 | } |
| 42 | |
| 43 | getMouseEventMap () { |
| 44 | return { |
| 45 | mousemove: this.handleMouseMove, |
| 46 | mouseup: this.handleMouseUp |
| 47 | }; |
| 48 | } |
| 49 | |
| 50 | getTouchEventMap () { |
| 51 | return { |
| 52 | touchmove: this.handleTouchMove, |
| 53 | touchend: this.handleTouchEnd |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | handleMouseMove = (event) => { |
| 58 | this.move(events.getMousePosition(event)); |
| 59 | }; |
| 60 | |
| 61 | handleTouchMove = (event) => { |
| 62 | this.move(events.getTouchPosition(event)); |
| 63 | }; |
nothing calls this directly
no test coverage detected