This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlimits.tsx
More file actions
271 lines (254 loc) · 13.9 KB
/
limits.tsx
File metadata and controls
271 lines (254 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SliderComponent, NumericTextBoxComponent, ChangeEventArgs as textboxChange } from '@syncfusion/ej2-react-inputs';
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
import { SampleBase } from '../common/sample-base';
import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons';
import { ChangeEventArgs as buttonChangeEvent } from '@syncfusion/ej2-buttons';
import { PropertyPane } from '../common/property-pane';
import { TooltipDataModel, TicksDataModel, LimitDataModel } from '@syncfusion/ej2-inputs';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
const slidercss = `
.content-wrapper {
width: 52%;
margin: 0 auto;
min-width: 185px;
}
.sliderwrap {
margin-top: 45px;
}
.e-bigger .content-wrapper {
width: 80%;
}
.sliderwrap label {
padding-bottom: 50px;
font-size: 13px;
font-weight: 500;
margin-top: 15px;
}
.userselect {
-webkit-user-select: none;
/* Safari 3.1+ */
-moz-user-select: none;
/* Firefox 2+ */
-ms-user-select: none;
/* IE 10+ */
user-select: none;
/* Standard syntax */
}
.property-custom td {
padding: 5px;
}
.property-custom .property-panel-content {
height: 320px;
}
`
export class Limits extends SampleBase<{}, {}> {
// Instance of the control
private minRangeObj: SliderComponent;
private rangeObj: SliderComponent;
private minStartObj: NumericTextBoxComponent;
private minEndObj: NumericTextBoxComponent;
private maxStartObj: NumericTextBoxComponent;
private maxEndObj: NumericTextBoxComponent;
private fixOneObj: CheckBoxComponent;
private fixTwoObj: CheckBoxComponent;
// Initialize ticks with placement, largestep, smallstep
private ticks: TicksDataModel = { placement: 'After', largeStep: 20, smallStep: 5, showSmallTicks: true };
private tooltip: TooltipDataModel = { isVisible: true, placement: 'Before' };
private minRangeLimits: LimitDataModel = { enabled: true, minStart: 10, minEnd: 40 };
private rangeLimits: LimitDataModel = { enabled: true, minStart: 10, minEnd: 40, maxStart: 60, maxEnd: 90 };
private minStart(args: textboxChange) {
this.minRangeObj.limits.minStart = args.value;
this.rangeObj.limits.minStart = args.value;
}
private minEnd(args: textboxChange) {
this.minRangeObj.limits.minEnd = args.value;
this.rangeObj.limits.minEnd = args.value;
}
private maxStart(args: textboxChange) {
this.minRangeObj.limits.maxStart = args.value;
this.rangeObj.limits.maxStart = args.value;
}
private maxEnd(args: textboxChange) {
this.minRangeObj.limits.maxEnd = args.value;
this.rangeObj.limits.maxEnd = args.value;
}
private fixOneChange(args: buttonChangeEvent) {
this.minRangeObj.limits.startHandleFixed = args.checked;
this.rangeObj.limits.startHandleFixed = args.checked;
}
private fixTwoChange(args: buttonChangeEvent) {
this.minRangeObj.limits.endHandleFixed = args.checked;
this.rangeObj.limits.endHandleFixed = args.checked;
}
public refreshTooltip(e: any): void {
if (!isNullOrUndefined(document.getElementById('minrange')) &&
!isNullOrUndefined((document.getElementById('minrange') as any).ej2_instances[0]) &&
!isNullOrUndefined(document.getElementById('range')) &&
!isNullOrUndefined((document.getElementById('range') as any).ej2_instances[0])) {
(document.getElementById('minrange') as any).ej2_instances[0].refreshTooltip();
(document.getElementById('range') as any).ej2_instances[0].refreshTooltip();
}
}
render() {
if (!isNullOrUndefined(document.getElementById('right-pane'))) {
document.getElementById('right-pane').addEventListener('scroll', this.refreshTooltip);
}
return (
<div className='control-pane'>
<div className='control-section'>
<div className='col-lg-8'>
<div className="content-wrapper">
<style>{slidercss}</style>
<div className='sliderwrap'>
<label>MinRange Slider With Limits</label>
{/* Initialize Slider Component with ticks with placement, largestep, smallstep */}
<SliderComponent id='minrange' value={25} min={0} max={100} ticks={this.ticks} limits={this.minRangeLimits} ref={(slider) => { this.minRangeObj = slider }} tooltip={this.tooltip} />
</div>
<div className='sliderwrap'>
<label>Range Slider With Limits</label>
{/* Initialize Range Slider Component with ticks with placement, largestep, smallstep */}
<SliderComponent id='range' value={[25, 75]} min={0} max={100} type='Range' limits={this.rangeLimits} ticks={this.ticks} tooltip={this.tooltip} ref={(slider) => { this.rangeObj = slider }} />
</div>
</div>
</div>
<div id="#slider_event" className='col-lg-4 property-section property-custom'>
<PropertyPane title='Properties'>
<table id="property" title="Properties">
<tbody>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">MinStart</div>
</td>
<td style={{ width: '50%' }}>
<NumericTextBoxComponent value={10} min={0} max={100} change={this.minStart.bind(this)} ref={(obj) => {
this.minStartObj = obj;
}} />
</td>
</tr>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">MinEnd</div>
</td>
<td style={{ width: '50%' }}>
<NumericTextBoxComponent value={40} min={0} max={100} change={this.minEnd.bind(this)} ref={(obj) => {
this.minEndObj = obj;
}} />
</td>
</tr>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">MaxStart</div>
</td>
<td style={{ width: '50%' }}>
<NumericTextBoxComponent value={60} min={0} max={100} change={this.maxStart.bind(this)} ref={(obj) => {
this.maxStartObj = obj;
}} />
</td>
</tr>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">MaxEnd</div>
</td>
<td style={{ width: '50%' }}>
<NumericTextBoxComponent value={90} min={0} max={100} change={this.maxEnd.bind(this)} ref={(obj) => {
this.maxEndObj = obj;
}} />
</td>
</tr>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">Lock First Handle</div>
</td>
<td style={{ width: '50%' }}>
<CheckBoxComponent ref={(scope) => { this.fixOneObj = scope; }} change={this.fixOneChange.bind(this)} />
</td>
</tr>
<tr>
<td style={{ width: '50%' }}>
<div className="userselect">Lock Second Handle</div>
</td>
<td style={{ width: '50%' }}>
<CheckBoxComponent ref={(scope) => { this.fixTwoObj = scope; }} change={this.fixTwoChange.bind(this)} />
</td>
</tr>
</tbody>
</table>
</PropertyPane>
</div>
<div id="action-description">
<p>This sample demonstrates the rendering of Slider component with limits. Drag the thumb over the bar for selecting the
values between assigned limit values. Change the values in the property pane to set different limit values.</p>
</div>
<div id="description">
<p>
The limits are used to limit between certain range. When the limits are assigned, draggable limited area will be
in the dark shadow color of the current theme. The limits APIs are explained below.
</p>
<p>
<table>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#minstart">minStart</a>
</td>
<td>
- Used to set minimum limit value for first handle.
</td>
</tr>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#minend">minEnd</a>
</td>
<td>
- Used to set maximum limit value for first handle.
</td>
</tr>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#maxstart">maxStart</a>
</td>
<td>
- Used to set minimum limit value for second handle.
</td>
</tr>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#maxend">maxEnd</a>
</td>
<td>
- Used to set maximum limit value for first handle.
</td>
</tr>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#starthandlefixed">startHandleFixed</a>
</td>
<td>
- Used to lock the first handle in the current position.
</td>
</tr>
<tr>
<td>
<a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/api-limitData.html?lang=es6#endhandlefixed">endHandleFixed</a>
</td>
<td>
- Used to lock the second handle in the current position.
</td>
</tr>
</table>
</p>
<p> In this demo, Limits with MinRange and range Slider is demonstrated.</p>
<ul>
<li>MinRange Slider – In this sample, the minimum and maximum limit of the slider is set to 10 and 40 respectively.</li>
<li>Range Slider – In this sample, the minimum and maximum limit of the first handle is set to 10 and 40 respectively
and the minimum and maximum limit of the second handle is set to 60 and 90 respectively.
</li>
</ul>
<p>For more information, refer to the <a target="_blank" href="http://ej2.syncfusion.com/documentation/slider/limits.html?lang=es6">limits</a> section from the documentation.</p>
</div>
</div>
</div>
)
}
}