react-range-slider-input
Advanced tools
Comparing version
@@ -49,4 +49,7 @@ "use strict"; | ||
this.options = {}; | ||
this.firstCall = true; | ||
this.isControlled = false; | ||
this.externalInput = false; | ||
this.isComponentMounted = false; | ||
this.lastValueProp = []; | ||
} | ||
@@ -131,2 +134,13 @@ | ||
reset() { | ||
this.isControlled = !!this.props.value; | ||
if (this.isControlled) { | ||
if (this.firstCall || this.props.value !== this.lastValueProp) { | ||
this.firstCall = false; | ||
this.externalInput = true; | ||
} | ||
this.lastValueProp = this.props.value; | ||
} | ||
this.maxRangeWidth = this.options.max - this.options.min; | ||
@@ -139,3 +153,2 @@ this.updateOrientation(); | ||
this.updateTabIndexes(); | ||
this.isControlled = !!this.props.value; | ||
} | ||
@@ -249,3 +262,3 @@ | ||
// which could change while changing min, max and step values | ||
const currentValue = this.setMinMaxProps(this.input[this.index.min].current.value, this.input[this.index.max].current.value); // var value is synced with the values set in the input elements if no newValue is passed | ||
const currentValue = this.setMinMaxProps(this.input[0].current.value, this.input[1].current.value); // var value is synced with the values set in the input elements if no newValue is passed | ||
@@ -277,7 +290,7 @@ newValue = newValue || currentValue; | ||
if (currentValue.min !== this.input[this.index.min].current.value || forceSet) { | ||
if (currentValue.min !== this.input[0].current.value || forceSet) { | ||
valueSet = true; | ||
} | ||
if (currentValue.max !== this.input[this.index.max].current.value || forceSet) { | ||
if (currentValue.max !== this.input[1].current.value || forceSet) { | ||
valueSet = true; | ||
@@ -293,6 +306,9 @@ } // Update the positions, dimensions and aria attributes everytime a value is set | ||
this.syncThumbDimensions(); | ||
this.updateThumbs(); | ||
this.updateRange(); | ||
this.updateAriaValueAttributes(); | ||
if (!this.isControlled || this.externalInput) { | ||
this.externalInput = false; | ||
this.syncThumbDimensions(); | ||
this.updateThumbs(); | ||
this.updateRange(); | ||
this.updateAriaValueAttributes(); | ||
} | ||
} | ||
@@ -449,3 +465,3 @@ } // Sync var value with the input elements | ||
if (!this.isControlled && !this.options.disabled && (this.doesntHaveClassName(e, 'range-slider__thumb') && this.doesntHaveClassName(e, 'range-slider__range') || this.options.rangeSlideDisabled && this.doesntHaveClassName(e, 'range-slider__thumb'))) { | ||
if (!this.options.disabled && (this.doesntHaveClassName(e, 'range-slider__thumb') && this.doesntHaveClassName(e, 'range-slider__range') || this.options.rangeSlideDisabled && this.doesntHaveClassName(e, 'range-slider__thumb'))) { | ||
setFocus = true; | ||
@@ -520,3 +536,3 @@ } // No action if both thumbs are disabled | ||
drag(e) { | ||
if (this.isDragging && !this.isControlled) { | ||
if (this.isDragging) { | ||
const lastPos = this.currentPosition(e, this.range.current); | ||
@@ -594,3 +610,3 @@ const delta = lastPos - this.startPos; | ||
if (!this.options.disabled && !this.options.thumbsDisabled[this.currentIndex(i)] && !this.isControlled) { | ||
if (!this.options.disabled && !this.options.thumbsDisabled[this.currentIndex(i)]) { | ||
let step = this.actualStepValue(); | ||
@@ -597,0 +613,0 @@ step = step === ANY ? 1 : step; |
{ | ||
"name": "react-range-slider-input", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "React component wrapper for range-slider-input", |
36267
0.85%648
2.05%