Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Slider - max value (not end of slider)
    primarykey
    data
    text
    <p>I have a stepped slider, with non-linear steps - </p> <p>code:</p> <pre><code>$(function() { var trueValues = [5, 10, 20, 50, 100, 150]; var values = [10, 20, 30, 40, 60, 100]; var slider = $("#parkSlider").slider({ orientation: 'horizontal', range: "min", value: 40, slide: function(event, ui) { var includeLeft = event.keyCode != $.ui.keyCode.RIGHT; var includeRight = event.keyCode != $.ui.keyCode.LEFT; var value = findNearest(includeLeft, includeRight, ui.value); slider.slider('value', value); $("#amount").val(getRealValue(value)); return false; }, }); function findNearest(includeLeft, includeRight, value) { var nearest = null; var diff = null; for (var i = 0; i &lt; values.length; i++) { if ((includeLeft &amp;&amp; values[i] &lt;= value) || (includeRight &amp;&amp; values[i] &gt;= value)) { var newDiff = Math.abs(value - values[i]); if (diff == null || newDiff &lt; diff) { nearest = values[i]; diff = newDiff; } } } return nearest; } function getRealValue(sliderValue) { for (var i = 0; i &lt; values.length; i++) { if (values[i] &gt;= sliderValue) { return trueValues[i]; } } return 0; } </code></pre> <p>Here's my slider graphic:</p> <p><img src="https://i.stack.imgur.com/m3Jdw.png" alt="slider"></p> <p>I have the minimum value set to be at the 5 in the graphic, but I am trying to set the max (value &amp; position) to stop at the 150 in the graphic. No matter what I've tried, the slider goes to the full end of the slider, and I always want it to stop short at the 150.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload