-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
106 lines (83 loc) · 2.52 KB
/
main.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
let vh = window.innerHeight * 0.01;
// Then we set the value in the --vh custom property to the root of the document
document.documentElement.style.setProperty('--vh', `${vh}px`);
let doneTime = 8000;
let doneTimer;
let done = false;
let circleGen;
let circleTimer = 1000;
let colorNumber = 0;
let colors = ['#634ea0', '#f9d49b', '#8a712f', '#e7c21f', '#76a56d', '#f89943', '#e42432', ]
$('.finger-spot').bind('mousedown touchstart', circlePop);
$('.finger-spot').bind('mouseup touchend', function(){
clearInterval(circleGen);
clearTimeout(doneTimer);
$('.finger-spot').removeClass('active');
$('#in-1').hide();
$('#in-1').html('Analysing');
$('#in-0').show();
});
function circlePop(e) {
e.preventDefault();
if (done) {
return;
}
$('.finger-spot').addClass('active');
makeCircle(e.pageX, e.pageY)
circleGen = setInterval(function() {makeCircle(e.pageX, e.pageY)}, circleTimer);
doneTimer = setTimeout(function() {vitacoon(e.pageX, e.pageY)}, doneTime);
}
function makeCircle(x, y) {
analyzing()
let circle = $('<div></div>');
circle.addClass('circle');
circle.css('background-color', colors[colorNumber])
$('.container').append(circle);
let size = parseInt(circle.css('height')) / 2;
circle.css('top', y - size);
circle.css('left', x - size);
if (colorNumber == colors.length) {
colorNumber = 0;
} else {
colorNumber += 1;
}
return circle;
}
function analyzing() {
$('#in-0').hide();
$('#in-1').show();
$('#in-1').html(function(_, currentcontent){
return currentcontent + '.';
})
}
function vitacoon(x, y) {
clearInterval(circleGen);
$('.calculating').addClass('inactive');
done = true;
let resultNo = Math.floor(Math.random() * colors.length);
// let resultNo = 0;
colorNumber = resultNo;
circle = makeCircle(x, y);
circle.addClass('main-color');
$('.scanner').addClass('down');
$('.communication').addClass('done');
$('.title').addClass('dissappear');
$('#' + resultNo).addClass('show');
setTimeout(
function() {
$('#' + resultNo).addClass('active');
}, 2000
);
setTimeout(
function() {
$('.calculating').addClass('hide');
}, 500
);
setTimeout(
function() {
$('body').css('background-color', colors[resultNo]);
$('.circle').remove();
}, 5000
);
}