Skip to content

Commit 7265433

Browse files
committed
version 1.2.3
1 parent 4f2e9aa commit 7265433

File tree

7 files changed

+47
-21
lines changed

7 files changed

+47
-21
lines changed

CHANGELOG renamed to CHANGELOG.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
1.2.3
2+
------------------
3+
* Some minor cleanup and bug fixes.
4+
15
1.2.2 (2018-12-12)
26
------------------
3-
* Add isDragging fix to click-hold functionality.
7+
* Added isDragging fix to click-hold functionality.
48

59
1.2.1 (2018-12-12)
610
------------------

build/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ class App extends React.Component {
2020
render() {
2121
return <div>
2222
<p>Here's an example RangeStepInput:</p>
23-
<RangeStepInput
24-
min={0} max={100}
25-
value={this.state.value} step={1}
26-
onChange={this.onChange.bind(this)}
27-
/>
23+
<div className="input-group mb-3">
24+
<RangeStepInput
25+
min={0} max={100}
26+
value={this.state.value} step={1}
27+
onChange={this.onChange.bind(this)}
28+
/>
29+
<div className="input-group-append">
30+
<span className="input-group-text ml-2">
31+
{this.state.value}
32+
</span>
33+
</div>
34+
</div>
2835
</div>;
2936
};
3037
onChange(e) {

lib/RangeStepInput.jsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ export default class RangeStepInput extends React.Component {
4646
this.setState({isMouseDown: true});
4747

4848
if (this.props.hold) {
49+
if (this.holdLoop) {
50+
clearInterval(this.holdLoop);
51+
}
52+
4953
const oldVal = this.props.value;
54+
5055
const self = this;
5156
// Add some initial delay on the click-hold functionality.
5257
setTimeout(function() {
@@ -70,7 +75,7 @@ export default class RangeStepInput extends React.Component {
7075
}
7176
}
7277
onInput(e) {
73-
const step = forceNumber(e.target.step);
78+
const step = this.props.step;
7479
const newVal = forceNumber(e.target.value);
7580
const oldVal = this.props.value;
7681

@@ -86,6 +91,9 @@ export default class RangeStepInput extends React.Component {
8691
}
8792
makeHoldLoop(oldVal) {
8893
const self = this;
94+
if (this.holdLoop) {
95+
clearInterval(this.holdLoop);
96+
}
8997

9098
return setInterval(function() {
9199
if (!self.state.isMouseDown || self.state.isDragging) {
@@ -98,15 +106,21 @@ export default class RangeStepInput extends React.Component {
98106
}
99107

100108
const input = self.domRef.current;
101-
102109
let newVal = self.props.value;
103-
if (oldVal > newVal) {
110+
111+
if (
112+
oldVal > newVal &&
113+
(newVal - self.props.step) >= self.props.min
114+
) {
104115
newVal -= self.props.step;
105-
} else if (oldVal < newVal) {
116+
} else if (
117+
oldVal < newVal &&
118+
(newVal + self.props.step) <= self.props.max
119+
) {
106120
newVal += self.props.step;
107-
} else {
108-
// The user is just holding the cursor at the current
109-
// value, so don't do anything.
121+
}
122+
123+
if (oldVal === newVal) {
110124
return false;
111125
}
112126

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const forceNumber = function(n) {
77
if (isNaN(n) || typeof n === 'undefined') {
88
n = 0;
99
}
10-
return Math.round(n * 100) / 100;
10+
return n;
1111
};
1212

1313
export {forceNumber};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dev": "webpack --mode development --watch",
88
"build": "webpack --mode=production",
99
"build-demo": "webpack --config webpack.config.docs.js --mode production",
10+
"build-demo-dev": "webpack --config webpack.config.docs.js --mode development --watch",
1011
"eslint": "eslint lib/"
1112
},
1213
"repository": {

0 commit comments

Comments
 (0)