Change value only on mouse up event with range sliders

For practice, I’m working on adding transitions to Mike’s Horizon Chart.

Here is my fork:

I’ve resorted to using the “Submit” button option with @jashkenas’s inputs. This is a great start, but I want to improve the behavior by

  1. updating the value to the right of the slider as you slide so you can see what number you’re about to submit before submitting it
  2. replacing the submit button with a mouseup event and/or an event that fires after x milliseconds if the mouse button is still clicked but not released.

The issue in this case, is that the transitions can take a long time to process and we need a way to throttle changes to the input values to avoid an overload of transition requests.

I’ve tried to do this with a _.debounce function but the problem is that the function keeps getting updated with every change and thus defeating the purpose.

I also looked for a way to define a function as non-mutable, but couldn’t see how to do that.

1 Like

Hey John,

Sure - good question! Here’s a fork of Jeremy’s notebook that adds a cautious parameter to the range input type:

The HTML5 range input doesn’t quite have an event that describes a user being ‘done’ using it, so this approximate such an event by waiting for keyup, mouseup, or touchend events and only updating the external value then - but updating the internal value preview immediately.


Hi Tom,

Awesome! I think that’s exactly what I need. Thank you for pointing it out to me.

It raises an idea/feature regarding forks. I suppose I could have somehow manually found and read all the forks – but it would be super useful to be able to search with in the scope of a base fork and/or a category/tag and then highlight any matches within the context of the search results. I guess something like what you see in a google search result.

Just an idea.



Here is a patched Inputs bazaar which shows the range value before you submit it, among other patches:

It may be still useful to you.