gpt4 book ai didi

javascript - 如何在特定数字处停止翻转计时器

转载 作者:行者123 更新时间:2023-11-28 00:12:31 25 4
gpt4 key购买 nike

我正在玩一个不会停止的计数器。我希望它停在特定的数字上。

// Initialize a new counter
var myCounter = new flipCounter('flip-counter', {
value: 0,
inc: 1,
pace: 6,
auto: true
});

我认为这将是以下内容:

if (flipCounter.value > 10) {
myCounter.stop();
}

如果有人能指出我正确的方向,我将不胜感激。

最佳答案

使用incrementTo(num, time,pace)

来自their文档:

incrementTo(num, time, pace) new Increments to a given number either by using the currently set pace and inc values, or by using a "smart" increment technique that determines optimal values for you. To use the simple technique, all you need to supply is the target number: myCounter.incrementTo(12345); This will increment to 12,345 using the current pace and inc values. To use the smart method, supply the time in seconds you want the increment process to last, and a desired pace: myCounter.incrementTo(12345, 10, 400); This will increment to 12,345 as well, but the increment process will take 10 seconds to complete. The counter will determine the optimal values to use. In the example I've set a desired pace of 400, which the counter will try and stay as close to as possible when finding the optimal values. This method is not chainable. num [int]: Number to increment to. time [int] (optional): Duration, in seconds, the increment process should take. When set, the counter will use a smart increment technique to optimize the animation. pace [int] (optional): Desired pace for animation when using the smart increment option. This number may increase as needed for optimal timing.

关于javascript - 如何在特定数字处停止翻转计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30767917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com