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

clicking the pips to move the closest slider (e.g. expose getClosestHandle somehow) #1014

Open
frumbert opened this issue Jul 31, 2019 · 1 comment
Labels
Feature Feature requests/suggestions

Comments

@frumbert
Copy link

frumbert commented Jul 31, 2019

I have a slider with 3 handles. I'm using clickable pips to move a slider to that position - here's my pip click handler:

	document.body.addEventListener("click", globalClickHandler);
	function globalClickHandler(e) {
		if (!e.target) return;
		if (e.target.classList.contains("noUi-value")) { // click a pip
			var pip = Number(e.target.dataset.value),
				range = document.getElementById('range'),
				curr = range.noUiSlider.get().map(Number);
			curr[1] = pip; // set middle handle
			range.noUiSlider.set(curr);
		} else //...

Is there any easy way to move the closest slider to the value I want to set, rather than just updating the entire state of the ranges through .set() - I see there's an internal getClosestHandle method for calculating positions for tapping on the range but this uses a percentage rather than the raw number value I'm storing on the pips.

@leongersen
Copy link
Owner

There's also methods available to transform between the percentage- and value domains, so exposing this method could be a nice added feature.

@leongersen leongersen added the Feature Feature requests/suggestions label Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature requests/suggestions
2 participants