admin管理员组文章数量:1311033
I am having trouble getting FlipClock.js to stop after it reaches a specific count. I have tried using the "clock.stop();
" call but it doesn't work even after many attempts to set a "stop" number. This is the code I have that works for my counter:
<script type="text/javascript">
var clock;
$(document).ready(function() {
// Instantiate a counter
clock = new FlipClock($('.clock'), {
clockFace: 'Counter',
minimumDigits: 4,
});
setTimeout(function() {
setInterval(function() {
clock.increment();
}, 0.1);
});
});
</script>
Any ideas as to how to set my counter to stop at "300"? Any help is greatly appreciated!
I am having trouble getting FlipClock.js to stop after it reaches a specific count. I have tried using the "clock.stop();
" call but it doesn't work even after many attempts to set a "stop" number. This is the code I have that works for my counter:
<script type="text/javascript">
var clock;
$(document).ready(function() {
// Instantiate a counter
clock = new FlipClock($('.clock'), {
clockFace: 'Counter',
minimumDigits: 4,
});
setTimeout(function() {
setInterval(function() {
clock.increment();
}, 0.1);
});
});
</script>
Any ideas as to how to set my counter to stop at "300"? Any help is greatly appreciated!
Share Improve this question edited Jul 31, 2014 at 3:21 Humayun Shabbir 3,2694 gold badges22 silver badges33 bronze badges asked Jul 30, 2014 at 13:59 SproutSprout 651 silver badge6 bronze badges2 Answers
Reset to default 5EDIT: FlipClock callbacks not being called
There appears to be a bug in the FlipClock callbacks.
Here's an alternative solution (you appear to have a lot of extra code, not sure why, this is a trimmed down version):
var clock,countup;
clock = new FlipClock($('h1'), {
clockFace: 'Counter',
minimumDigits: 4
});
countup = setInterval(function() {
if(clock.getTime().time > 300) {
clock.stop();
clearInterval(countup);
}
},500);
Check flipclockjs. for the documentation on callbacks.
The following is an example:
var clock,countup;
clock = new FlipClock($('.clock'), {
clockFace: 'Counter',
minimumDigits: 4,
callbacks: {
interval: function() {
var time = clock.getTime().time;
if(time > 300) { clearInterval(countup); }
}
}
});
setTimeout(function() {
countup = setInterval(function() { clock.increment(); }, 0.1);
});
You rock Adam... This is what worked in the end...
var clock,countup;
clock = new FlipClock($('.clock'), {
clockFace: 'Counter',
minimumDigits: 4,
});
countup = setInterval(function() {
clock.increment();
if(clock.getTime().time > 300) {
clock.stop();
clearInterval(countup);
}
}, 0);
本文标签: javascriptGetting FlipClockjs to stop after counting up to a numberStack Overflow
版权声明:本文标题:javascript - Getting FlipClock.js to stop after counting up to a number - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741834345a2400123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论