forked from infoshareacademy/jfdz5-4apple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (41 loc) · 1.26 KB
/
script.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
$(function () {
var pictures = $('.container-team');
var picturesPositionTop = pictures.position().top;
var now = $('.animation');
var second = $('.animation-first');
$(window).scroll(function () {
if (parseInt($(window).scrollTop() + $(window).height() - 400) > (picturesPositionTop)) {
if (now.hasClass('animation')) {
now.removeClass('animation').addClass('animation-team');
second.removeClass('animation-first').addClass('animation-second');
}
}
});
});
// KOD NA WPISANIE SLOWA "GAME"
var helper = {
allowed: [101, 109, 97, 103],
stored: [],
checker: function (first, second) {
return first.toString() === second.toString() ? true : false;
},
push: function (letter) {
helper.stored.unshift(letter);
},
action: function () {
$('.game-container').show().css({
display: 'flex'
});
}
};
document.addEventListener("keypress", function (e) {
if (helper.stored.length > 3) {
helper.stored.pop();
}
var event = e || window.event,
keyCode = event.keyCode || event.charCode;
helper.push(keyCode);
if (helper.checker(helper.allowed, helper.stored)) {
helper.action();
}
});