-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
132 lines (111 loc) · 3.59 KB
/
index.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
var carousel = $('#examples-carousel');
carousel.on('slide.bs.carousel', function (e) {
let incomingTitle = $('.example-title')[e.to];
let incomingImage = $('.example-image')[e.to];
let outgoingImage = $('.example-image')[e.from];
let incomingCarouselItem = $('.carousel-item')[e.to];
let outgoingBackground = $('.item-background')[e.from];
/* TRANSPARENT BACKGROUND */
// hide the current background to prevent overlapping transparent space
$(outgoingBackground).css('opacity', '0');
// then put it back once it's off screen
setTimeout(() => {
$(outgoingBackground).css('opacity', '.7');
}, 1500);
/* EXPLODING TEXT */
// hide all text except the outgoing text
$('.carousel-item-text').each(function(index) {
if (index == e.from) {
$(this).css('opacity', '1');
} else {
$(this).css('opacity', '0');
}
});
// after 500ms, hide all text except the incoming text
setTimeout(function() {
$('.carousel-item-text').each(function(index) {
if (index == e.to) {
$(this).css('opacity', '1');
} else {
$(this).css('opacity', '0');
}
});
}, 500);
// there's a bug with this where if you move the carousel and then move it again in the opposite direction before
// the movement is complete, you can get stuck with some small amount of extra margin on the text, it's some problem
// with the code below. maybe it can be fixed by just making the margins go back to zero instead of these "+- a certain number"
// move summary text horizontally
$('.summary').each(function() {
$(this).transition({
marginLeft: (e.from > e.to) ? "+=3000" : "-=3000"
}, 600, function() {
// then make (new) summary go back
$(this).transition({
marginLeft: (e.from > e.to) ? "-=3000" : "+=3000"
}, 550, function() {
// finished
});
});
});
// move technologies down
$('.technologies').each(function() {
$(this).transition({
marginTop: "+=2000"
},550, function() {
// then make (new) technologies go back up
$(this).transition({
marginTop: "-=2000"
}, 550, function() {
// finished
});
});
});
/* FADING IMAGE AND TITLE */
// fade in incoming title and image
// these won't work unless I do a timeout... otherwise the carousel slide animation doesn't work
setTimeout(function() {
$(incomingTitle).css('opacity', '0');
$(incomingTitle).transition({
opacity: '1'
},1600);
}, 400);
setTimeout(function() {
$(incomingImage).css('opacity', '0');
$(incomingImage).transition({
opacity: '1'
},1600);
}, 400);
// because I have to do a timeout above, I have to hide the entire slide during this time or it'll flash
$(incomingCarouselItem).css('opacity', '0');
setTimeout(() => {
$(incomingCarouselItem).css('opacity', '1');
}, 410);
// fade out outgoing image
setTimeout(function() {
$(outgoingImage).transition({
opacity: "0"
},500, function() {
// then restore opacity
$(outgoingImage).css('opacity', '1');
});
}, 700);
}); // end of carousel.on('slide.bs.carousel'...
$("#about-modal").on('shown.bs.modal', function(){
$('#about-modal-close-button').focus();
});
function showAboutModal() {
$('#about-modal').modal();
}
function showProjectsModal() {
$('#projects-modal').modal();
}
function goToSlide(number) {
$('#projects-modal').modal('hide');
if ($('.navbar-toggler').attr('aria-expanded') === "true") {
$('.navbar-toggler').click();
}
$("#examples-carousel").carousel(number);
}
$(document).ready(() => {
showAboutModal();
});