Skip to content
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

Moving the slider handles programmatically by step size #221

Closed
jace opened this issue Mar 21, 2014 · 4 comments
Closed

Moving the slider handles programmatically by step size #221

jace opened this issue Mar 21, 2014 · 4 comments

Comments

@jace
Copy link

jace commented Mar 21, 2014

I'm trying to get keyboard integration working with two text fields for the left and right slider handles, where pressing Up or Down in the text field increments or decrements the corresponding handle. Unfortunately, my slider has custom step ranges:

var slider = $("#slider").noUiSlider({
  start: [0, 10000000],
  step: 1,
  connect: true,
  behaviour: "tap",
  range: {
    'min': [0, 5000],
    '5%':  [100000, 10000],
    '80%': [1000000, 50000],
    '90%': [2000000, 100000],
    'max': [10000000, 1000000],
  },
  /* Serialization options */
});

This is a problem because if I try to do the following in my input field, incrementing by 1 or even 10 no longer works. I have to increment by 5000 until I reach 100,000, and then increment by 10,000:

$("#input-min").keydown(function(e) {
  // Convert the string to a number.
  var value = Number(slider.val()[0]);
  // 38 is key up,
  // 40 is key down.
  switch ( e.which ) {
    case 38:
      slider.val([value + 10, null]);
      e.preventDefault();
      break;
    case 40:
      slider.val([value - 10, null]);
      e.preventDefault();
      break;
  };
});

It'll be nice if I can instead use something like slider.val(['+1', null]), telling NoUiSlider to increment by one step, whatever the current step is.

@leongersen
Copy link
Owner

True. This is an issue I hadn't considered, I'll put some time in to adding this feature. Thanks for the clear description!

@leongersen leongersen added this to the 6.3 milestone May 18, 2014
@leongersen
Copy link
Owner

This'll be in the next version.

leongersen added a commit that referenced this issue May 18, 2014
@leongersen
Copy link
Owner

It took a while, but getCurrentStep is in noUiSlider 7. Have a look at the Changing the slider by keypress example for the implementation.

@github-actions
Copy link

github-actions bot commented Jun 8, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants