Reset Slider value to zero

172
1
Jump to solution
10-08-2020 12:15 PM
GregoryBologna
Occasional Contributor

I am using a Slider widget and would like to have its value reset to zero when the clear button is clicked. I was hoping there was a property or method for this.

I also noticed in the sample here that the slider doesn't reset to zero after the clear button is clicked.

SceneLayerView - query statistics by geometry | ArcGIS API for JavaScript 4.17 

Slider | ArcGIS API for JavaScript 4.17 

<div aria-label="Slider value" aria-labelledby="bufferNum-label-0" aria-orientation="horizontal" aria-valuemax="500" aria-valuemin="0" aria-valuenow="72" aria-valuetext="72ft" class="esri-slider__anchor esri-slider__anchor-0 esri-slider__anchor--moved" id="bufferNum-handle-0" touch-action="none" role="slider" style="left: 14.40083%" tabindex="0"><span class="esri-slider__thumb" touch-action="none"></span><span class="esri-slider__label" id="bufferNum-label-0" touch-action="none">72ft</span></div>

            const bufferNumSlider = new Slider({
              container: "bufferNum",
              min: 0,
              max: 500,
              steps: 1,
              visibleElements: {
                labels: true
              },
              precision: 0,
              labelFormatFunction: function (valuetype) {
                return value.toString() + "ft";
              },
              values: [0]
            });

            bufferNumSlider.tickConfigs = [{
              mode: "position",
              labelsVisible: true,
              values: [0250500]
            }];

            // get user entered values for buffer
            bufferNumSlider.on(
              ["thumb-change""thumb-drag"],
              bufferVariablesChanged
            );
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Contributor

You can set the Slider widget back to zero by updating Slider.values, for example: slider.values = [0];

 

Here's an example using the sample you mentioned above: https://codepen.io/annefitz/pen/mdEebEN 

I added bufferNumSlider.values = [0]; to the clearGeometry function at line 205.

View solution in original post

0 Kudos
1 Reply
AnneFitz
Esri Contributor

You can set the Slider widget back to zero by updating Slider.values, for example: slider.values = [0];

 

Here's an example using the sample you mentioned above: https://codepen.io/annefitz/pen/mdEebEN 

I added bufferNumSlider.values = [0]; to the clearGeometry function at line 205.

View solution in original post

0 Kudos