0

I have customise the ion range slider according to need. just need simple functionalities
1. Label needs to be in center .
2. On label click handle should be move accordingly.
3. Color gap between two values in color line.

I have tried to create "cut slider like given ref" ref here : (https://www.jamesallen.com/loose-diamonds/all-diamonds/)

I have created sample fiddle here please see for ref:

[a link](https://jsfiddle.net/rudratosh/7wg1p86e/3/)

https://jsfiddle.net/rudratosh/7wg1p86e/3/

what is not working is:
1. first if we click on "FAIR" label so it should not move anywhere in first. unlike is behaving.

  1. same if i click on fair left its working fine but just a bit right its moving wrong . please see given ref for more clarity.

Thanks in advance

Coder
  • 184
  • 15

2 Answers2

1

In order to do you intend there will be some steps to follow: 1. Add an extra item to your values (Set it to empty. You will notice that in the grid slider the value will be ZERO. 2. In your CSS file, add a display none to the first grid item. 3. Modify your rangeslider js function.

//Define list in your backend
$scale_list = array("","FAIR", "GOOD", "VERY GOOD", "EXCELLENT");`

//HTML component
<div data-parent="cut" class="inline">
    <p class="sub-panel-title" data-filter="cut">Cut <i class="fa fa-question"></i></p>
    <div class="slider cut-filter">
        <input type="text" class="inline cut grid-slider js-range-slider" data-filter="cut" data-type="doubled" data-grid="true" data-values="{','|implode:$scale_list}" data-from="0" data-to="{count($scale_list)-1}" name="cut" data-from-max="{count($scale_list)-2}" data-to-min="1" value=""/>
    </div>
</div>

//CSS 
.irs-grid-text.js-grid-text-0{display: none}

//JS Code
$(".cut-filter .grid-slider.js-range-slider").ionRangeSlider({
    skin:"sharp",
    onStart:function(data){
        var slider_obj = data.input.parents(".slider").find("span.irs-grid-text");
        $.each(slider_obj, function() {
            if(!$(this).hasClass("js-grid-text-0")){
                var left_percent = $(this).get(0).style.left;
                var minus_value =5;
                var modified_percent = parseInt(left_percent)-minus_value;
                $(this).css("left", modified_percent+'%');
            }
        });
    },
    onFinish: function (data) {
        var instance = data.input.data("ionRangeSlider");
        //var referrer = $('.diamonds .filters').data('referrer');
        instance.options['to_min']= data.from+1;
        instance.options['from_max']= data.to-1;

        data.input.addClass('modified');
        //fetchDiamonds();
    }
});
0

this is a very custom functionality and is not supported from the box. Possible solution - extra grid, build outside. https://jsfiddle.net/IonDen/xnadtv74/

Click on this grid could call sliders update method to reposition handle.

IonDen
  • 773
  • 5
  • 15