简体   繁体   中英

Jquery plugin FlipClockjs Doesn't work

I just started using the FlipClock js using this:

var clock;
$(document).ready(function() {
    clock = $('.clock').FlipClock(3600 * 24 * 3, {
        clockFace: 'DailyCounter',
        countdown: true,
        autostart: true
    });
});

The clock does display,but the timer is not working.

ie: The clock timer doesn't flip.

I tried replacing the clockFace to "HourlyCounter" and it worked perfectly. But doesn't work on "DailyCounter".

Is this a bug or is it just me?

A bad if condition inside flipclock.js is the culprit at around line 482 inside the method

flip: function(time, doNotAddPlayClass) 

Please change the following code snipet

if (!t.factory.time.time instanceof Date) {
    if(!t.factory.countdown) {
        t.factory.time.time++;
    }
    else {
        if(t.factory.time.time <= 0) {
            t.factory.stop();
        }

        t.factory.time.time--;
    }
}

to

if (!(t.factory.time.time instanceof Date)) { //-- would satisfy condition in this case.
    if(!t.factory.countdown) {
        t.factory.time.time++;
    }
    else {
        if(t.factory.time.time <= 0) {
            t.factory.stop();
        }

        t.factory.time.time--;
    }
}

have you tried using Cookies? use clock.getTime() to get the last date time data before user leave your page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM