Slider not set correctly when updating value.
See original GitHub issueBased on Slider with dates example in the docs, if I try to move from date range index manually, even though index and value match to one of the values in the date range it doesn’t update correctly. I’ve already tried to use setTimeout approach and manualRefresh.emit() one too. The only way I’ve seen it actually update the value correctly is by toggling it with an *ngIf, which causes the illusion of blinking and it’s not desirable.
Here’s my code:
setUpDates() {
this.dateRange = this.createRange();
this.minValue = this.dateRange[15].getTime();
this.currentTickIndex = 15;
// this.maxValue = this.dateRange[29].getTime();
this.options = {
stepsArray: this.dateRange.map((date: any) => {
return { value: new Date(date).getTime() };
}),
translate: (value: number): string => new Date(value)
.toLocaleTimeString('en-GB', { hour12: true, hour: '2-digit', minute: '2-digit' })
};
}
createRange(): Date[] {
const dates: Date[] = [];
const start = moment(this.date).add(-15, 'minutes');
for (let i = 0; i <= 30; i++) {
dates.push(new Date(start.year(), start.month(), start.day(), start.hours(), start.minutes() + i));
}
return dates;
}
onChange(e: any) {
this.currentTickIndex = this.options.stepsArray.findIndex(item => item.value === e.value);
}
moveTick(index) {
this.currentTickIndex += index;
if (this.currentTickIndex < 0) {
this.currentTickIndex = 0;
} else if (this.currentTickIndex > 30) {
this.currentTickIndex = 30;
}
// this.minValue = this.dateRange[this.currentTickIndex].getTime();
this.minValue = this.options.stepsArray[this.currentTickIndex].value;
// this.hideSlider = true;
setTimeout( () => {
this.options = Object.assign({}, this.options);
this.manualRefresh.emit();
});
// this.hideSlider = false;
}
Any hint would be very appreciated. Thanks in advance.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Slider not set correctly when updating value. · Issue #53 - GitHub
I've already tried to use setTimeout approach and manualRefresh.emit() one too. The only way I've seen it actually update the value correctly is ......
Read more >jquery - Slider won't update properly - Stack Overflow
I am using the JQuery slider UI Widget. I am getting weird problems when using two sliders in the same form. I tried...
Read more >UI Slider does not update when value is loaded - Unity Forum
So currently I have an options menu that updates the volume when the slider is changed. I am able to save the volume...
Read more >InputSlider not updating on binding change
Hi,. I'm having issue with the MDBInputRange component. Expected behavior Updating the slider value through updating the slider property value.
Read more >Solved: Range control in gallery not updating
Solved: Hey there, I've added a range control to a gallery template to allow the user to change a certain value of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It worked! Thanks a lot!
What is the version of slider that you are using? I just fixed a similar issue #52 in v1.1.11.