objectivehtml/FlipClock

When the countdown ends, it doesn't stop

slmholder opened this issue · 2 comments

"flipclock": "^0.10.8",

import React from 'react'
import './compiled/flipclock.css'
import FlipClock from 'flipclock'

const el = document.getElementById('myClock')
const nowSeconds = new Date().getTime() / 1000;
const end = new Date((nowSeconds + this.state.countDownTime) * 1000)
this.clock = new FlipClock(el, end, {
face: 'DayCounter',
countdown: true,
autoStart: true,
callbacks: {
stop: function() {
this.props.getDownloadList(this.state.ID)
}
}
});

To zero but continues to operate as a negative value
Is it because I configured it?
thank you

Hey I had trouble with this also. Just figured out a solution. I used underscore forEach, but you can iterate however you want. It basically checks the face values to see if they are all 0's. If they are, I manually stop the timer.

timer = new FlipClock(el, end, {
	countdown: true,
	showLabels: false,
	autoStart: false
});
			
timer.start();
timer.$timer.on('interval', function(){
	var complete = true;
	_.forEach(timer.$face.$value.$digits, function(time){
		_.forEach(time, function(digit){
			if(Number.parseInt(digit, 10) > 0){
				complete = false;
			}
		});
	});

	if(complete){
		timer.stop();
	}
});

@tbone849 Thank you very much for your thoughts. The problem has been solved. Thanks again.