Skip to content

Make change event always fire as the user interacts with the knob #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2013

Conversation

amuino
Copy link
Contributor

@amuino amuino commented Nov 20, 2013

That is, when using:

  • touch
  • wheel
  • typing (by binding to the "input" event)

Previously, typing did not update the knob until focus was lost (and
no change event was fired), and
using the keyboard arrows did not fire any change events.

Also move event triggering to val() and change() so it works always
in the same way and less duplication exists.

Similar to #130 but fixes an issue with diplayPrevious

That is, when using:
- touch
- wheel
- typing (by binding to the "input" event)

Previously, typing did not update the knob until focus was lost (and
no change event was fired), and
using the keyboard arrows did not fire any change events.

Also move event triggering to val() and change() so it works always
in the same way and less duplication exists.

Similar to aterrien#130 but fixes an issue with `diplayPrevious`
aterrien added a commit that referenced this pull request Nov 20, 2013
Make change event always fire as the user interacts with the knob @amuino
@aterrien aterrien merged commit 11a0a89 into aterrien:master Nov 20, 2013
@aterrien
Copy link
Owner

Thank you amuino !

@ACXgit
Copy link

ACXgit commented Dec 7, 2013

Hi amuino, after this merge I started to experiment troubles in my application. After a long investigation I found that this new behaviour introduces a sort of... loop. I use:

$('.dial').val(27).trigger('change');

to set the value, as the documentation tells. I cycle that in a setInterval to animate the knob, used as a playback progress of an audio player. The problem is that, since this version, change the value also means to execute the change hook functions (correct me if I'm wrong). This was not happening before, as I used the change event to do a clearInterval when the knob was clicked/touched. Now it executes the clearInterval at the first cycle of setInterval, and my playback progress knob is not working anymore :)
Can I avoid this issue with a workaround?

@amuino
Copy link
Contributor Author

amuino commented Dec 7, 2013

@ACXgit that is the kind of inconsistencies that I wanted to avoid… so we kind of need opposite things!

Anyway, I think you can workaround it on your event handlers by using some flag. Something like…

setInterval(function() { 
  $('.dial').data('mute', true).val(27).trigger('change').data('mute', false);
}

... and then on the event handler ...

function handler() {
  if ($('.dial').data('mute') == true) return;
  // standard handling
}

(I've written that from memory, so there might be errors and better options for your specific code)

@ACXgit
Copy link

ACXgit commented Dec 7, 2013

Thank you for the suggested workaround, but sadly it does not work in my case, because I need change event to not interfere with the whole setInterval cycle: playback progress must advance setting the value step by step with setInterval and be stopped ONLY when users click/touch on the knob. I appreciate the need to avoid inconsistencies, but at least give the possibility to set knob's value and manage the change event independently in some way, or it may be impossible to manage cases like mine.

I also noticed a possibly worse issue after this merge: I can't see the numeric indicator change while dragging the knob with the mouse. The value changes only when I release the mouse. In previous versions that wasn't the default behaviour (the value was changing in real time).
If confirmed, this is an usability issue, because it forces the user to guess the exact desired value in a a trial-and-error approach. Please revert the behaviour to the previous standard.

aterrien added a commit that referenced this pull request Dec 7, 2013
@aterrien
Copy link
Owner

aterrien commented Dec 7, 2013

Afraid to affect everyone :)

@robertc
Copy link

robertc commented Apr 14, 2014

This got reverted? Any chance it can be added again? Not having the change event fire for changes with mousewheel is quite annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants