FlipClock icon indicating copy to clipboard operation
FlipClock copied to clipboard

When the countdown ends, it doesn't stop

Open slmholder opened this issue 5 years ago • 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

slmholder avatar Jan 13 '21 10:01 slmholder

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 avatar Jan 16 '21 15:01 tbone849

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

slmholder avatar Jan 19 '21 05:01 slmholder