Closed venelinpetrov closed 8 years ago
When you change the value of the input the knob will update automatically. So what to you mean with "support all events"?
Strangely, I've tried just that, but it didn't work as I expected. Could you please review what's not correct in my code? Given the input: <input id="knob2" class="preset2" type="range" min="0" max="44" data-width="160" data-height="160" data-angleoffset="220" data-anglerange="280" tabindex="-1" data-value="2">
var knob = new Knob(document.getElementById('knob2'), new Ui.P2());
knob.input.addEventListener('input', function(e){
console.log(e.currentTarget.value);
}, false);
knob.input.value = 3;
I appreciate your help much, and really like the library. Thanks again.
I ran into the same issue, and also that the input
or change
events on the input element don't work.
This is super frustrating; effectively makes this tool almost pointless to use.
The knob function listen to change events of the input. By just setting the inputs value no event is triggered. You need to trigger the event by yourself:
knob.input.dispatchEvent(new Event('change'))
But if this is really a problem I can add a update
method to change the value and update the knob.
knob.update(newValue)
Ok, now you can change the value by knob.update(newValue)
and you can listen to change
events on the input field.
Thank you @eskimoblood!
Do you support any events, so we can actually get/set values to the knobs? Thanks.