其他分享
首页 > 其他分享> > 使用fullpage插件与countup插件实现到某一页时执行计数功能

使用fullpage插件与countup插件实现到某一页时执行计数功能

作者:互联网

将使用countup的函数封装到立即执行函数当中并在afterLoad回调函数中进行判断,当页数为某页时执行封装的触发countup的函数。

 $(function(){
            $('#frame').fullpage({
                afterLoad:function (origin) {
                    //设置计数器
                    if (origin.index == 0){
                        $(function () {
                            var options = {
                                useEasing: true,
                                useGrouping: true,
                                separator: ',',
                                decimal: '.'
                            };
                            var number1 = new CountUp('number1', 0, 4, 0, 3, options);
                            var number2 = new CountUp('number2', 0, 180, 0, 3, options);
                            var number3 = new CountUp('number3', 0, 400, 0, 3, options);
                            var number4 = new CountUp('number4', 0, 900, 0, 3, options);
                            var number5 = new CountUp('number5', 0, 2000, 0, 3, options);
                            var number6 = new CountUp('number6', 0, 6000, 0, 3, options);
                            var number7 = new CountUp('number7', 0, 10000, 0, 3, options);
                            var number8 = new CountUp('number8', 0, 50000, 0, 3, options);
                            number1.start();
                            setTimeout(function () {
                                number2.start()
                            },500)
                            setTimeout(function () {
                                number3.start()
                            },1000)
                            setTimeout(function () {
                                number4.start()
                            },1500)
                            setTimeout(function () {
                                number5.start()
                            },2500)
                            setTimeout(function () {
                                number6.start()
                            },3000)
                            setTimeout(function () {
                                number7.start()
                            },4000)
                            setTimeout(function () {
                                number8.start()
                            },5000)

                        })
                    }

标签:function,插件,fullpage,start,new,var,countup,CountUp,options
来源: https://blog.csdn.net/qq_39608986/article/details/97915225