Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the countdown ends, it doesn't stop #415

Open
slmholder opened this issue Jan 13, 2021 · 2 comments
Open

When the countdown ends, it doesn't stop #415

slmholder opened this issue Jan 13, 2021 · 2 comments

Comments

@slmholder
Copy link

slmholder commented Jan 13, 2021

"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

@tbone849
Copy link

tbone849 commented Jan 16, 2021

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();
	}
});

@slmholder
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants