jquery ui slider / proportional handle

demo of attempts at jquery ui slider with proportional handle

by hrabinowitz

HTML

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<h1>
  demo of attempts at jquery ui slider with proportional handle
</h1>
<div id="slider">
  <div id="custom-handle" class="ui-slider-handle"></div>
</div>

CSS

#custom-handle {
  width: 120px;
  height: 1.6em;
  top: 50%;
  /*margin-top: -.8em;*/
	margin-left: 0;
  text-align: center;
  line-height: 1.6em;
}

#slider {
  width: 80%;
}

JavaScript

var handle = $("#custom-handle");
  $("#slider").slider({
    create: function() {
      handle.text($(this).slider("value"));
    },
    slide: function(event, ui) {
			if (ui.value > 75) {
				event.preventDefault();
				return;
			}
      handle.text(ui.value);
    }
  });