55 <div class =" w-full flex justify-between" >
66 <h1 class =" text-xl text-purple-matcha capitalize" >{{ name }}</h1 >
77 <h1 class =" text-xl text-purple-matcha" >
8- <span class =" " >{{this.slider.startMin}} {{this.unit}}</span >
9- to
10- <span class =" " >{{this.slider.startMax}} {{this.unit}}</span ></h1 >
8+ <span class =" " >{{this.slider.startMin}}< span v-if = " oneHandle " > {{this.unit}}</ span > </span >
9+ < span v-if = " !oneHandle " > to </ span >
10+ <span v-if = " !oneHandle " class =" " >{{this.slider.startMax}} {{this.unit}}</span ></h1 >
1111 </div >
1212 </div >
1313 <div ref =" slider" class =" mx-auto w-full mb-4 px-4 max-w-md" ></div >
@@ -19,7 +19,7 @@ import noUiSlider from 'nouislider';
1919import ' nouislider/distribute/nouislider.css' ;
2020
2121export default {
22- props: [' options' , ' name' , ' unit' , ' min' , ' max' ],
22+ props: [' options' , ' name' , ' unit' , ' min' , ' max' , ' oneHandle ' ],
2323 data : () => ({
2424 slider: {
2525 startMin: null ,
@@ -36,8 +36,14 @@ export default {
3636 this .slider .min = this .min ;
3737 this .slider .max = this .max ;
3838 this .slider .start = this .min ;
39+ let start;
40+ if (this .oneHandle ) {
41+ start = 0 ;
42+ } else {
43+ start = [this .slider .startMin , this .slider .startMax ];
44+ }
3945 noUiSlider .create (this .$refs .slider , {
40- start: [ this . slider . startMin , this . slider . startMax ] ,
46+ start,
4147 step: this .slider .step ,
4248 range: {
4349 min: this .slider .min ,
@@ -47,7 +53,7 @@ export default {
4753 this .$refs .slider .noUiSlider .on (' update' , (values ) => {
4854 this .slider .startMin = parseInt (values[0 ], 10 );
4955 this .slider .startMax = parseInt (values[1 ], 10 );
50- this .$emit (' saveFilter' , this .name , this .slider .startMin , this .slider .startMax );
56+ this .$emit (' saveFilter' , this .name , this .slider .startMin , this .slider .startMax , this . oneHandle );
5157 });
5258 },
5359};
0 commit comments