fc-react-slider
Version:
A fully featured slider component made in React
25 lines (21 loc) • 3.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* Returns the new value Array or string based on which control is changed and
* type of slider
* @param currentVal : current value of the slider (Array | Number)
* @param newValue : value of one control (Number)
* @param changed : 'lower' or 'upper'
* @param type : 'range' or 'value'
* @returns {*}
*/
exports.default = function (currentVal, newValue, changed, type) {
var val = newValue;
if (type === 'range') {
if ((typeof newValue === 'undefined' ? 'undefined' : _typeof(newValue)) === 'object') return newValue;
val = changed === 'lower' ? [newValue, currentVal[1]] : [currentVal[0], newValue];
}
return val;
};