@@ -118,13 +118,13 @@ export default {
118118 }
119119 } ,
120120 methods : {
121- __setActive ( event ) {
121+ __getDragging ( event ) {
122122 let
123123 container = this . $refs . handle ,
124124 width = container . offsetWidth ,
125125 sensitivity = ( this . dragOnlyRange ? - 1 : 1 ) * this . $refs . handleMin . offsetWidth / ( 2 * width )
126126
127- this . dragging = {
127+ let dragging = {
128128 left : container . getBoundingClientRect ( ) . left ,
129129 width,
130130 valueMin : this . model . min ,
@@ -134,7 +134,7 @@ export default {
134134 }
135135
136136 let
137- percentage = getPercentage ( event , this . dragging , this . $q . i18n . rtl ) ,
137+ percentage = getPercentage ( event , dragging , this . $q . i18n . rtl ) ,
138138 type
139139
140140 if ( percentage < this . currentMinPercentage + sensitivity ) {
@@ -143,10 +143,10 @@ export default {
143143 else if ( percentage < this . currentMaxPercentage - sensitivity ) {
144144 if ( this . dragRange || this . dragOnlyRange ) {
145145 type = dragType . RANGE
146- extend ( this . dragging , {
146+ extend ( dragging , {
147147 offsetPercentage : percentage ,
148148 offsetModel : getModel ( percentage , this . min , this . max , this . step , this . computedDecimals ) ,
149- rangeValue : this . dragging . valueMax - this . dragging . valueMin ,
149+ rangeValue : dragging . valueMax - dragging . valueMin ,
150150 rangePercentage : this . currentMaxPercentage - this . currentMinPercentage
151151 } )
152152 }
@@ -161,89 +161,84 @@ export default {
161161 }
162162
163163 if ( this . dragOnlyRange && type !== dragType . RANGE ) {
164- setTimeout ( ( ) => {
165- this . dragging = false
166- } , 100 )
167- return
164+ return false
168165 }
169166
170- this . dragging . type = type
171- this . __update ( event )
167+ dragging . type = type
168+ return dragging
172169 } ,
173- __update ( event ) {
170+ __move ( event , dragging = this . dragging ) {
174171 let
175- percentage = getPercentage ( event , this . dragging , this . $q . i18n . rtl ) ,
172+ percentage = getPercentage ( event , dragging , this . $q . i18n . rtl ) ,
176173 model = getModel ( percentage , this . min , this . max , this . step , this . computedDecimals ) ,
177174 pos
178175
179- switch ( this . dragging . type ) {
176+ switch ( dragging . type ) {
180177 case dragType . MIN :
181- if ( percentage <= this . dragging . percentageMax ) {
178+ if ( percentage <= dragging . percentageMax ) {
182179 pos = {
183180 minP : percentage ,
184- maxP : this . dragging . percentageMax ,
181+ maxP : dragging . percentageMax ,
185182 min : model ,
186- max : this . dragging . valueMax
183+ max : dragging . valueMax
187184 }
188185 }
189186 else {
190187 pos = {
191- minP : this . dragging . percentageMax ,
188+ minP : dragging . percentageMax ,
192189 maxP : percentage ,
193- min : this . dragging . valueMax ,
190+ min : dragging . valueMax ,
194191 max : model
195192 }
196193 }
197194 break
198195
199196 case dragType . MAX :
200- if ( percentage >= this . dragging . percentageMin ) {
197+ if ( percentage >= dragging . percentageMin ) {
201198 pos = {
202- minP : this . dragging . percentageMin ,
199+ minP : dragging . percentageMin ,
203200 maxP : percentage ,
204- min : this . dragging . valueMin ,
201+ min : dragging . valueMin ,
205202 max : model
206203 }
207204 }
208205 else {
209206 pos = {
210207 minP : percentage ,
211- maxP : this . dragging . percentageMin ,
208+ maxP : dragging . percentageMin ,
212209 min : model ,
213- max : this . dragging . valueMin
210+ max : dragging . valueMin
214211 }
215212 }
216213 break
217214
218215 case dragType . RANGE :
219216 let
220- percentageDelta = percentage - this . dragging . offsetPercentage ,
221- minP = between ( this . dragging . percentageMin + percentageDelta , 0 , 1 - this . dragging . rangePercentage ) ,
222- modelDelta = model - this . dragging . offsetModel ,
223- min = between ( this . dragging . valueMin + modelDelta , this . min , this . max - this . dragging . rangeValue )
217+ percentageDelta = percentage - dragging . offsetPercentage ,
218+ minP = between ( dragging . percentageMin + percentageDelta , 0 , 1 - dragging . rangePercentage ) ,
219+ modelDelta = model - dragging . offsetModel ,
220+ min = between ( dragging . valueMin + modelDelta , this . min , this . max - dragging . rangeValue )
224221
225222 pos = {
226223 minP,
227- maxP : minP + this . dragging . rangePercentage ,
224+ maxP : minP + dragging . rangePercentage ,
228225 min : parseFloat ( min . toFixed ( this . computedDecimals ) ) ,
229- max : parseFloat ( ( min + this . dragging . rangeValue ) . toFixed ( this . computedDecimals ) )
226+ max : parseFloat ( ( min + dragging . rangeValue ) . toFixed ( this . computedDecimals ) )
230227 }
231228 break
232229 }
233230
234231 this . currentMinPercentage = pos . minP
235232 this . currentMaxPercentage = pos . maxP
236- this . __updateInput ( pos )
233+ this . model = {
234+ min : pos . min ,
235+ max : pos . max
236+ }
237237 } ,
238- __end ( ) {
238+ __end ( event , dragging = this . dragging ) {
239+ this . __move ( event , dragging )
239240 this . currentMinPercentage = ( this . model . min - this . min ) / ( this . max - this . min )
240241 this . currentMaxPercentage = ( this . model . max - this . min ) / ( this . max - this . min )
241- this . __endEmit ( )
242- } ,
243- __updateInput ( { min = this . model . min , max = this . model . max } ) {
244- const model = { min, max}
245- this . model = model
246- this . $emit ( 'input' , model )
247242 } ,
248243 __validateProps ( ) {
249244 if ( this . min >= this . max ) {
0 commit comments