-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
61 lines (60 loc) · 1.91 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
$(document).ready(function () {
var animating = false,
submitPhase1 = 1100,
submitPhase2 = 400,
logoutPhase1 = 800,
$login = $(".login"),
$app = $(".app");
function ripple(elem, e) {
$(".ripple").remove();
var elTop = elem.offset().top,
elLeft = elem.offset().left,
x = e.pageX - elLeft,
y = e.pageY - elTop;
var $ripple = $("<div class='ripple'></div>");
$ripple.css({
top: y,
left: x
});
elem.append($ripple);
}
$(document).on("click", ".login__submit", function (e) {
if (animating) return;
animating = true;
var that = this;
ripple($(that), e);
$(that).addClass("processing");
setTimeout(function () {
$(that).addClass("success");
setTimeout(function () {
$app.show();
$app.css("top");
$app.addClass("active");
}, submitPhase2 - 70);
setTimeout(function () {
$login.show();
$login.addClass("inactive");
animating = false;
$(that).removeClass("success processing");
}, submitPhase2);
}, submitPhase1);
});
$(document).on("click", ".app__logout", function (e) {
if (animating) return;
$(".ripple").remove();
animating = true;
var that = this;
$(that).addClass("clicked");
setTimeout(function () {
$app.removeClass("active");
$login.show();
$login.css("top");
$login.removeClass("inactive");
}, logoutPhase1 - 120);
setTimeout(function () {
$app.hide();
animating = false;
$(that).removeClass("clicked");
}, logoutPhase1);
});
});