question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"format" option breaks the slider completely

See original GitHub issue

Here’s the reduced case. If you remove the format : { … } section, everything works (well, except the custom formatting). It looks like your code sends NaN as parameters to the from() and to() methods.

<link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/9.0.0/nouislider.min.css" rel="stylesheet" type="text/css">
<div id="range"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/9.0.0/nouislider.min.js" type="text/javascript"></script>
<script>
	var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
	slider = document.getElementById('range');
	slider.style.width = "50%";
	slider.style.margin = "50px";
	var date_range = {min: 1468951379, max: 1477116021};
	var options = {
		start: [date_range.min, date_range.max],
		connect: true,
		range: date_range,
		format: {
			to: function(v){
				var a = new Date(v * 1000);
				return months[a.getMonth()] + " " + a.getDate();
			},
			from: function(v) {
				var a = new Date(v * 1000);
				return months[a.getMonth()] + " " + a.getDate();
			}
		},
		tooltips: true
	};
	noUiSlider.create(slider, options);
</script>
`

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
i-failcommented, Nov 8, 2016

leongersen, your comment made me test a few things. Turns out from() method actually gets a number, not a string - you can console.log it, if you don’t believe me.

So this change made everything work:

        format: {
            to: function(v){                
                var a = new Date(v * 1000);
                return months[a.getMonth()] + " " + a.getDate();
            },
            from: function(v) {
                return v;
            }
        },

0reactions
github-actions[bot]commented, May 31, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep the Formatting of an Inserted Slide in PowerPoint
After pasting a new slide into the slide thumbnails on the left, look for the "Paste Options" icon at the bottom-right of the...
Read more >
Slider Question - Qualtrics
The slider question will reformat on mobile screens so that all the necessary information fits if you go to Format and select Mobile...
Read more >
Working with Slides - ProPresenter User Guide
First, put the cursor where you would like the text to break between slides, then either click the Insert Slide Break button on...
Read more >
7.3 Slide formatting | R Markdown: The Definitive Guide
Every new slide is created under three dashes ( --- ). The dashes must be directly followed by a line break, and there...
Read more >
Guides for arranging things on a slide in PowerPoint
Press Shift to select multiple objects. Select Picture Format > Align and select type of alignment: Align Left, Align Center, or Align Right....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found