src/common/createSlider.tsx
changed.
src/Range.tsx
changed.
70 | 70 | ||
71 | 71 | onMouseUpListener: any; |
|
72 | 72 | ||
73 | - | inTrack: boolean; |
|
73 | + | dragTrack: boolean; |
|
74 | 74 | ||
75 | 75 | startBounds: number[]; |
|
76 | 76 |
109 | 109 | const value = draggableTrack && this.positionGetValue ? this.positionGetValue(p) || [] : []; |
|
110 | 110 | ||
111 | 111 | const inPoint = utils.isEventFromHandle(e, this.handlesRefs); |
|
112 | - | this.inTrack = |
|
112 | + | this.dragTrack = |
|
113 | 113 | draggableTrack && |
|
114 | 114 | bounds.length >= 2 && |
|
115 | 115 | !inPoint && |
120 | 120 | }) |
|
121 | 121 | .some((c) => !c); |
|
122 | 122 | ||
123 | - | if (this.inTrack) { |
|
123 | + | if (this.dragTrack) { |
|
124 | 124 | this.dragOffset = p; |
|
125 | 125 | this.startBounds = [...bounds]; |
|
126 | 126 | } else { |
158 | 158 | ||
159 | 159 | onFocus = (e: React.FocusEvent<HTMLDivElement>) => { |
|
160 | 160 | const { onFocus, vertical } = this.props; |
|
161 | - | if (utils.isEventFromHandle(e, this.handlesRefs) && !this.inTrack) { |
|
161 | + | if (utils.isEventFromHandle(e, this.handlesRefs) && !this.dragTrack) { |
|
162 | 162 | const handlePosition = utils.getHandleCenterPosition(vertical, e.target); |
|
163 | 163 | this.dragOffset = 0; |
|
164 | 164 | this.onStart(handlePosition); |
171 | 171 | ||
172 | 172 | onBlur = (e: React.FocusEvent<HTMLDivElement>) => { |
|
173 | 173 | const { onBlur } = this.props; |
|
174 | - | if (!this.inTrack) { |
|
174 | + | if (!this.dragTrack) { |
|
175 | 175 | this.onEnd(); |
|
176 | 176 | } |
|
177 | 177 |
192 | 192 | return; |
|
193 | 193 | } |
|
194 | 194 | const position = utils.getMousePosition(this.props.vertical, e); |
|
195 | - | this.onMove(e, position - this.dragOffset, this.inTrack, this.startBounds); |
|
195 | + | this.onMove(e, position - this.dragOffset, this.dragTrack, this.startBounds); |
|
196 | 196 | }; |
|
197 | 197 | ||
198 | 198 | onTouchMove = (e: React.TouchEvent<HTMLDivElement>) => { |
202 | 202 | } |
|
203 | 203 | ||
204 | 204 | const position = utils.getTouchPosition(this.props.vertical, e); |
|
205 | - | this.onMove(e, position - this.dragOffset, this.inTrack, this.startBounds); |
|
205 | + | this.onMove(e, position - this.dragOffset, this.dragTrack, this.startBounds); |
|
206 | 206 | }; |
|
207 | 207 | ||
208 | 208 | onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => { |
113 | 113 | ||
114 | 114 | handlesRefs: Record<number, any>; |
|
115 | 115 | ||
116 | - | inTrack: boolean; |
|
116 | + | dragTrack: boolean; |
|
117 | 117 | ||
118 | 118 | constructor(props: RangeProps) { |
|
119 | 119 | super(props); |
255 | 255 | this.removeDocumentEvents(); |
|
256 | 256 | ||
257 | 257 | if (!handle) { |
|
258 | - | this.inTrack = false; |
|
258 | + | this.dragTrack = false; |
|
259 | 259 | } |
|
260 | 260 | if (handle !== null || force) { |
|
261 | 261 | this.props.onAfterChange(this.getValue()); |
266 | 266 | }); |
|
267 | 267 | }; |
|
268 | 268 | ||
269 | - | onMove(e, position, inTrack, startBounds) { |
|
269 | + | onMove(e, position, dragTrack, startBounds) { |
|
270 | 270 | utils.pauseEvent(e); |
|
271 | 271 | const { state, props } = this; |
|
272 | 272 | const maxValue = props.max || 100; |
|
273 | 273 | const minValue = props.min || 0; |
|
274 | - | if (inTrack) { |
|
274 | + | if (dragTrack) { |
|
275 | 275 | const max = maxValue - Math.max(...startBounds); |
|
276 | 276 | const min = minValue - Math.min(...startBounds); |
|
277 | 277 | const ratio = Math.min(Math.max(position / (this.getSliderLength() / 100), min), max); |
Files | Coverage |
---|---|
src | 88.46% |
Project Totals (11 files) | 88.46% |