pixuireactcomponents 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -27,6 +27,9 @@ export interface SliderProps {
|
|
|
27
27
|
overallWidth?: number;
|
|
28
28
|
onIncClick?: Function | null;
|
|
29
29
|
onDecClick?: Function | null;
|
|
30
|
+
rangeControl?: Boolean;
|
|
31
|
+
startRange?: number;
|
|
32
|
+
endRange?: number;
|
|
30
33
|
}
|
|
31
34
|
export declare class Slider extends Component<SliderProps, {
|
|
32
35
|
percent: number;
|
|
@@ -80,6 +80,12 @@ var Slider = /** @class */ (function (_super) {
|
|
|
80
80
|
// this.setState({
|
|
81
81
|
// discrete: Math.round(newPercent),
|
|
82
82
|
// })
|
|
83
|
+
if (_this.props.rangeControl) {
|
|
84
|
+
if (_this.props.endRange != null)
|
|
85
|
+
_this.discrete = Math.min(_this.discrete, _this.props.endRange);
|
|
86
|
+
if (_this.props.startRange != null)
|
|
87
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
88
|
+
}
|
|
83
89
|
newPercent = _this.discrete * (100 / _this.props.maxDiscrete);
|
|
84
90
|
}
|
|
85
91
|
_this.setState({
|
|
@@ -112,10 +118,14 @@ var Slider = /** @class */ (function (_super) {
|
|
|
112
118
|
}
|
|
113
119
|
};
|
|
114
120
|
_this.onDecClick = function () {
|
|
121
|
+
//离散的情况
|
|
115
122
|
if (_this.props.isDiscrete && _this.props.maxDiscrete) {
|
|
116
123
|
if (_this.discrete >= 1) {
|
|
117
|
-
var newPercent = (_this.discrete - 1) * (100 / _this.props.maxDiscrete);
|
|
118
124
|
_this.discrete -= 1;
|
|
125
|
+
if (_this.props.rangeControl && _this.props.startRange != null) {
|
|
126
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
127
|
+
}
|
|
128
|
+
var newPercent = _this.discrete * (100 / _this.props.maxDiscrete);
|
|
119
129
|
_this.setState({
|
|
120
130
|
//discrete: this.state.discrete - 1,
|
|
121
131
|
percent: newPercent
|
|
@@ -126,6 +136,7 @@ var Slider = /** @class */ (function (_super) {
|
|
|
126
136
|
});
|
|
127
137
|
}
|
|
128
138
|
}
|
|
139
|
+
//连续的情况
|
|
129
140
|
else {
|
|
130
141
|
if (_this.state.percent > 0) {
|
|
131
142
|
_this.setState({
|
|
@@ -139,10 +150,14 @@ var Slider = /** @class */ (function (_super) {
|
|
|
139
150
|
}
|
|
140
151
|
};
|
|
141
152
|
_this.onIncClick = function () {
|
|
153
|
+
//离散的情况
|
|
142
154
|
if (_this.props.isDiscrete && _this.props.maxDiscrete) {
|
|
143
155
|
if (_this.discrete < _this.props.maxDiscrete) {
|
|
144
|
-
var newPercent = (_this.discrete + 1) * (100 / _this.props.maxDiscrete);
|
|
145
156
|
_this.discrete += 1;
|
|
157
|
+
if (_this.props.rangeControl && _this.props.startRange != null) {
|
|
158
|
+
_this.discrete = Math.max(_this.discrete, _this.props.startRange);
|
|
159
|
+
}
|
|
160
|
+
var newPercent = _this.discrete * (100 / _this.props.maxDiscrete);
|
|
146
161
|
_this.setState({
|
|
147
162
|
// discrete: this.state.discrete + 1,
|
|
148
163
|
percent: newPercent
|
|
@@ -153,6 +168,7 @@ var Slider = /** @class */ (function (_super) {
|
|
|
153
168
|
});
|
|
154
169
|
}
|
|
155
170
|
}
|
|
171
|
+
//连续的情况
|
|
156
172
|
else {
|
|
157
173
|
if (_this.state.percent < 100) {
|
|
158
174
|
_this.setState({
|