Spaces:
Sleeping
Sleeping
File size: 1,979 Bytes
b5de3c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
// Init
var $ = jQuery;
var animationTime = 20,
days = 7;
$(document).ready(function(){
// timer arguments:
// #1 - time of animation in mileseconds,
// #2 - days to deadline
$('#progress-time-fill, #death-group').css({'animation-duration': animationTime+'s'});
var deadlineAnimation = function () {
setTimeout(function(){
$('#designer-arm-grop').css({'animation-duration': '1.5s'});
},0);
setTimeout(function(){
$('#designer-arm-grop').css({'animation-duration': '1s'});
},4000);
setTimeout(function(){
$('#designer-arm-grop').css({'animation-duration': '0.7s'});
},8000);
setTimeout(function(){
$('#designer-arm-grop').css({'animation-duration': '0.3s'});
},12000);
setTimeout(function(){
$('#designer-arm-grop').css({'animation-duration': '0.2s'});
},15000);
};
function timer(totalTime, deadline) {
var time = totalTime * 1000;
var dayDuration = time / deadline;
var actualDay = deadline;
var timer = setInterval(countTime, dayDuration);
function countTime() {
--actualDay;
$('.deadline-days .day').text(actualDay);
if (actualDay == 0) {
clearInterval(timer);
$('.deadline-days .day').text(deadline);
}
}
}
var deadlineText = function () {
var $el = $('.deadline-days');
var html = '<div class="mask-red"><div class="inner">' + $el.html() + '</div></div><div class="mask-white"><div class="inner">' + $el.html() + '</div></div>';
$el.html(html);
};
deadlineText();
deadlineAnimation();
timer(animationTime, days);
setInterval(function(){
timer(animationTime, days);
deadlineAnimation();
console.log('begin interval', animationTime * 1000);
}, animationTime * 1000);
}); |