How to display the last count value using "stop" function?
User0123456789 opened this issue · 5 comments
I tried to use $('.timer').countTo('stop'); but the last count value is missing.
Mind sharing a code example of the issue on jsfiddle or something similar?
I'm trying to stop the counting when the time reached between 10:01 pm to 9:59:59 am. My else if is working but the counting is not stopping until I reload the page.
Here's my current code
if(curr_time >= '10:00:01' && curr_time <= '22:00:59'){
$('.timer').countTo({
from: current_data,
to: 1000000,
speed: speed,
refreshInterval: 100,
onUpdate: function (value){
sessionStorage.setItem("counterData", value);
},
onComplete: function(value){
console.debug(this);
}
});
} else if(curr_time >= '22:01:00' && curr_time <= '9:59:59'){
$('.timer').countTo({
from: temp_data,
to: temp_data
});
}
I tried to do the code below but the data is not displayed.
if(curr_time >= '10:00:01' && curr_time <= '22:00:59'){
$('.timer').countTo({
from: current_data,
to: 1000000,
speed: speed,
refreshInterval: 100,
onUpdate: function (value){
sessionStorage.setItem("counterData", value);
},
onComplete: function(value){
console.debug(this);
}
});
} else if(curr_time >= '22:01:00' && curr_time <= '9:59:59'){
$('#timer').countTo('stop'){
from: temp_data,
to: temp_data
}
}
It looks like you're trying to call:
$('#timer').countTo('stop'){
from: temp_data,
to: temp_data
}
I don't think this is valid JS.
To clarify how the stop function works, you don't need to pass any arguments. It will also only be effective on a timer that was previously started by calling countTo
with config options passed in. e.g.:
$('.timer').countTo({
// config options
});
setTimeout(function() {
$('.timer').countTo('stop');
}, 5000);
I tried your snippet but the last value is not displayed. How to display the last count when I using $('.timer').countTo('stop');
?
You can just set it to whatever the last value should be through jQuery. See this example.