@@ -136,25 +136,10 @@ export default {
136
136
this .$emit (' change' , val);
137
137
},
138
138
finalLeft () {
139
- if (! this .vertical ) {
140
- let ratio =
141
- this .finalLeft / (this .barEl .width - this .btnEl .width );
142
- ratio = ratio * (this .maxinum - this .mininum ) + this .mininum ;
143
- if (this .moveable ) {
144
- this .progress = ratio .toFixed (0 );
145
- }
146
- }
139
+ if (this .moveable ) this .progress = this .setProgress ();
147
140
},
148
141
finalTop () {
149
- if (! this .barEl .height || ! this .btnEl .height ) return ;
150
- if (this .vertical ) {
151
- let ratio =
152
- this .finalTop / (this .barEl .height - this .btnEl .height );
153
- ratio = ratio * (this .maxinum - this .mininum ) + this .mininum ;
154
- if (this .moveable ) {
155
- this .progress = ratio .toFixed (0 );
156
- }
157
- }
142
+ if (this .moveable ) this .progress = this .setProgress (true );
158
143
}
159
144
},
160
145
computed: {
@@ -304,6 +289,7 @@ export default {
304
289
this .currentLeft =
305
290
toRatio * (this .barEl .width - this .btnEl .width );
306
291
}
292
+ if (! this .vertical ) this .progress = this .setProgress ();
307
293
break ;
308
294
}
309
295
}
@@ -322,6 +308,7 @@ export default {
322
308
this .currentTop =
323
309
toRatio * (this .barEl .height - this .btnEl .height );
324
310
}
311
+ if (this .vertical ) this .progress = this .setProgress (true );
325
312
break ;
326
313
}
327
314
}
@@ -352,6 +339,17 @@ export default {
352
339
this .currentLeft =
353
340
(this .progress / (this .maxinum - this .mininum )) *
354
341
(this .barEl .width - this .btnEl .width );
342
+ },
343
+ setProgress (vertical = false ) {
344
+ if (! vertical) {
345
+ let ratio =
346
+ this .finalLeft / (this .barEl .width - this .btnEl .width );
347
+ ratio = ratio * (this .maxinum - this .mininum ) + this .mininum ;
348
+ return ratio .toFixed (0 );
349
+ }
350
+ let ratio = this .finalTop / (this .barEl .height - this .btnEl .height );
351
+ ratio = ratio * (this .maxinum - this .mininum ) + this .mininum ;
352
+ return ratio .toFixed (0 );
355
353
}
356
354
}
357
355
};
0 commit comments