Repository URL to install this package:
|
Version:
4.0.116 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const mobx_1 = require("xmobx/mobx");
class RangeSliderStateInstance {
constructor(props) {
this.minValue = 0;
this.stepValue = props.stepValue;
this.maxValue = props.maxValue;
this.selectedMaxValue = props.selectedMaxValue === this.maxValue ? this.maxValue : props.selectedMaxValue;
this.selectedMinValue = props.selectedMinValue === this.minValue ? this.minValue : props.selectedMinValue;
this.selectedValue = props.maxValue;
this.initialMaxValue = props.maxValue;
}
setSelectedMin(targetValue) {
if (targetValue >= this.selectedMaxValue) {
this.selectedMinValue = this.selectedMaxValue - this.stepValue;
} else {
this.selectedMinValue = targetValue;
const overAllValue = this.maxValue / this.stepValue;
const stepValue = targetValue / this.stepValue;
this.minWidth = 100 / overAllValue * stepValue;
}
this.setSelectedValue();
}
setSelectedMax(targetValue) {
if (targetValue <= this.selectedMinValue) {
this.selectedMaxValue = this.selectedMinValue + this.stepValue;
} else {
this.selectedMaxValue = targetValue;
const overAllValue = this.maxValue / this.stepValue;
const stepValue = overAllValue - targetValue / this.stepValue;
this.maxWidth = 100 / overAllValue * stepValue;
}
this.setSelectedValue();
}
setSelectedValue() {
this.selectedValue = this.selectedMaxValue - this.selectedMinValue;
}
get optionList() {
const arrayOfObject = [];
let range = 0;
let index = 0;
for (range; range <= this.initialMaxValue; range = range + this.stepValue) {
if (range % this.stepValue === 0) {
const config = {
value: range,
index: index,
stepValue: this.stepValue
};
arrayOfObject.push(config);
index++;
}
}
return arrayOfObject;
}
}
tslib_1.__decorate([mobx_1.observable], RangeSliderStateInstance.prototype, "minValue", void 0);
tslib_1.__decorate([mobx_1.observable], RangeSliderStateInstance.prototype, "maxValue", void 0);
tslib_1.__decorate([mobx_1.observable], RangeSliderStateInstance.prototype, "selectedValue", void 0);
tslib_1.__decorate([mobx_1.observable], RangeSliderStateInstance.prototype, "selectedMaxValue", void 0);
tslib_1.__decorate([mobx_1.observable], RangeSliderStateInstance.prototype, "selectedMinValue", void 0);
tslib_1.__decorate([mobx_1.action.bound], RangeSliderStateInstance.prototype, "setSelectedMin", null);
tslib_1.__decorate([mobx_1.action.bound], RangeSliderStateInstance.prototype, "setSelectedMax", null);
tslib_1.__decorate([mobx_1.action.bound], RangeSliderStateInstance.prototype, "setSelectedValue", null);
tslib_1.__decorate([mobx_1.computed], RangeSliderStateInstance.prototype, "optionList", null);
exports.RangeSliderStateInstance = RangeSliderStateInstance; //# sourceMappingURL=state.js.map