This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
59 lines (56 loc) · 1.57 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
51
52
53
54
55
56
57
58
59
'use strict';
var React = require('react');
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var Range = React.createClass({
displayName: 'Range',
propTypes: {
onChange: React.PropTypes.func,
onClick: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
onMouseMove: React.PropTypes.func
},
getDefaultProps: function() {
return {
type: 'range',
onChange: function(){},
onClick: function(){},
onKeyDown: function(){},
onMouseMove: function(){}
};
},
onRangeChange: function(e) {
this.props.onMouseMove(e);
if (e.buttons !== 1 && e.which !== 1) return;
this.props.onChange(e);
},
onRangeClick: function(e) {
this.props.onClick(e);
this.props.onChange(e);
},
onRangeKeyDown: function(e) {
this.props.onKeyDown(e);
this.props.onChange(e);
},
setRangeRef: function(ref) {
this.range = ref;
},
componentWillReceiveProps: function(props) {
this.range.value = props.value;
},
render: function() {
var props = _extends({}, this.props, {
defaultValue: this.props.value,
onClick: this.onRangeClick,
onKeyDown: this.onRangeKeyDown,
onMouseMove: this.onRangeChange,
onChange: function() {},
ref: this.setRangeRef
});
delete props.value;
return React.createElement(
'input',
props
);
}
});
module.exports = Range;