diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-26 01:28:41 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-26 01:28:41 +0200 |
| commit | 8d06839056967e8786c63976545aff098ae2f128 (patch) | |
| tree | 51c83236b2dcc5a6adabb1b4036eccfff63b9ef5 /app/client/common/slider.component.js | |
| parent | bd354556f98aa724dd6cee03a1828bd40ce01f33 (diff) | |
morph module.. enum method for sliders
Diffstat (limited to 'app/client/common/slider.component.js')
| -rw-r--r-- | app/client/common/slider.component.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/client/common/slider.component.js b/app/client/common/slider.component.js index cc00650..468debd 100644 --- a/app/client/common/slider.component.js +++ b/app/client/common/slider.component.js @@ -52,6 +52,9 @@ class Slider extends Component { if (this.props.type === 'odd') { new_value = parseInt(Math.floor(new_value / 2) * 2 + 1) } + if (this.props.type === 'list') { + new_value = this.props.options[new_value] || this.props.options[0] + } this.setState({ value: new_value }) this.timeout = setTimeout(() => { this.props.live && this.props.actions.set_param(this.props.name, new_value) @@ -66,8 +69,17 @@ class Slider extends Component { } let text_value = value let step; + let min = this.props.min || 0 + let max = this.props.max || 0 if (this.props.type === 'int') { step = 1 + } else if (this.props.type === 'list') { + min = 0 + max = this.props.options.length-1 + step = 1 + console.log('old', value) + value = this.props.options.indexOf(value) + console.log('new', value, this.props.options[value]) } else { step = (this.props.max - this.props.min) / 100 text_value = parseFloat(value).toFixed(2) @@ -80,8 +92,8 @@ class Slider extends Component { </label> <input type='range' - min={this.props.min} - max={this.props.max} + min={min} + max={max} step={step} value={value} onInput={this.handleRange} |
