Skip to content

Commit 4f7994d

Browse files
issue #14 resolved and tested
1 parent 47dd38c commit 4f7994d

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

dash_daq/dash_daq.min.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.

dash_daq/dash_daq.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/deps/dash_daq.min.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.

inst/deps/dash_daq.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Knob.react.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ class Knob extends Component {
4949
this.onMouseUp = this.onMouseUp.bind(this);
5050
this.onMouseMove = this.onMouseMove.bind(this);
5151
this.setValue = this.setValue.bind(this);
52+
this.getValue = this.getValue.bind(this);
5253
}
5354

5455
noop() {}
5556

57+
getValue(value) {
58+
return value > this.props.min && value < this.props.max
59+
? value
60+
: this.props.min > value
61+
? this.props.min
62+
: this.props.max;
63+
}
64+
5665
UNSAFE_componentWillReceiveProps(newProps) {
5766
if (typeof newProps.value !== 'undefined') this.setState({ value: newProps.value });
5867
if (this.state.max != newProps.max) {
@@ -138,7 +147,7 @@ class Knob extends Component {
138147
const progress = computeProgress({
139148
min,
140149
max,
141-
value: value > min && value < max ? value : (min + max) / 2,
150+
value: this.getValue(value),
142151
progressionTarget: 1
143152
});
144153

@@ -180,12 +189,12 @@ class Knob extends Component {
180189
{...this.state}
181190
min={this.props.min != this.state.min ? this.props.min : this.state.min}
182191
max={this.props.max != this.state.max ? this.props.max : this.state.max}
183-
value={value > min && value < max ? value : (min + max) / 2}
192+
value={this.getValue(value)}
184193
scale={generateScale(this.props)}
185194
currentDeg={valueToDeg({
186195
min: this.props.min,
187196
max: this.props.max,
188-
value: value > min && value < max ? value : (min + max) / 2
197+
value: this.getValue(value)
189198
})}
190199
refFunc={ele => (this.knobElement = ele)}
191200
onMouseDown={disabled ? this.noop : this.onMouseDown}

0 commit comments

Comments
 (0)