Search code examples
javascriptjqueryflipclock

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?


Solution

  • 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--;
        }
    }