-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
272 lines (251 loc) · 9.34 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
var layoutButtonScrollMin = 1100;
var layoutButtonScrollMax = 1600;
var layoutButtonsActive = false;
var isAnimationActive = false;
var currentState = "title";
var carouselCaptions = [
"One of the many classrooms at Pleasanton Middle School. This is one of the rooms borrowed by Tzu Chi Chinese School. Many rooms have a similar group-oriented setup.",
"A floor plan of the common classroom at PMS. The teachers lecture for entire class periods, while some students struggle to see the board.",
"Wheeled, rotating chairs at Evans Hall served as inspiration. I believe using chairs like this will allow for more flexibility in the classroom.",
"In \"lecture\" mode, students can easily rearrange desks so everyone has line of sight. If a student's vision is blocked, he or she can easily reposition him/herself.",
"In \"group\" mode, students can rearrange desks into variable-size groups. In this way, teachers can employ both group-based and lecture-based lessons without worrying about desk arrangement."
];
var currentCarouselCaptionIndex = 1000;
function scrollToLayout() {
console.log("TEST");
$("body").animate({scrollTop: $("#layout-panel").offset().top}, 1000);
}
function showLayoutButtons() {
if (layoutButtonsActive || isAnimationActive)
return false;
console.log("showing layout buttons");
isAnimationActive = true;
$(".layout-button").show();
$("#layout-button-1").animate({
top: "5%",
opacity: 1
}, 950, function () {
layoutButtonsActive = true;
isAnimationActive = false;
});
$("#layout-button-2").animate({
top: "30%",
opacity: 1
}, 700);
$("#layout-button-3").animate({
top: "60%",
opacity: 1
}, 400);
$("#layout-button-4").animate({
top: "28%",
opacity: 1
}, 720);
$("#layout-button-5").animate({
top: "68%",
opacity: 1
}, 320);
return true;
}
function hideLayoutButtons() {
if (!layoutButtonsActive || isAnimationActive)
return false;
console.log("hiding layout buttons");
isAnimationActive = true;
$("#layout-button-1").animate({
top: "0px",
opacity: 0
}, 60);
$("#layout-button-2").animate({
top: "0px",
opacity: 0
}, 300);
$("#layout-button-3").animate({
top: "0px",
opacity: 0
}, 600);
$("#layout-button-4").animate({
top: "0px",
opacity: 0
}, 300);
$("#layout-button-5").animate({
top: "0px",
opacity: 0
}, 680, function () {
$(".layout-button").hide();
$(".layout-button").css("top", "100%");
layoutButtonsActive = false;
isAnimationActive = false;
});
return true;
}
function showLayoutButtonPanel(i) {
$("#layout-button-panel-" + i).fadeIn(500);
}
function hideLayoutButtonPanel(i) {
$("#layout-button-panel-" + i).fadeOut(500);
}
function bindMouseHoverFunctionsForLayoutButton(i) {
$("#layout-button-" + i).mouseover(function(e) {
$("#layout-button-" + i).animate({
"top": "-=10",
"left": "-=10",
"width": "+=20",
"height": "+=20",
"border-radius": "+=20px",
"font-size": "50"
}, 75);
});
$("#layout-button-" + i).mouseout(function(e) {
$("#layout-button-" + i).animate({
"top": "+=10",
"left": "+=10",
"width": "-=20",
"height": "-=20",
"border-radius": "-=20px",
"font-size": "35"
}, 75);
});
}
function bindMouseFunctionsForLayoutButtons() {
bindMouseHoverFunctionsForLayoutButton(1);
bindMouseHoverFunctionsForLayoutButton(2);
bindMouseHoverFunctionsForLayoutButton(3);
bindMouseHoverFunctionsForLayoutButton(4);
bindMouseHoverFunctionsForLayoutButton(5);
$("#layout-button-1").click(function(e) {
showLayoutButtonPanel(1);
});
$("#layout-button-2").click(function(e) {
showLayoutButtonPanel(2);
});
$("#layout-button-3").click(function(e) {
showLayoutButtonPanel(3);
});
$("#layout-button-4").click(function(e) {
showLayoutButtonPanel(4);
});
$("#layout-button-5").click(function(e) {
showLayoutButtonPanel(5);
});
}
function cycleCarouselCaptions(direction) {
if (direction == "left") {
$("#carousel-text").animate({
opacity: 0.1
}, 200, function() {
currentCarouselCaptionIndex++;
$("#carousel-text").text(carouselCaptions[currentCarouselCaptionIndex % 5])
$("#carousel-text").animate({
opacity: 1
}, 200);
});
} else if (direction == "right") {
$("#carousel-text").animate({
opacity: 0.1
}, 200, function() {
currentCarouselCaptionIndex--;
$("#carousel-text").text(carouselCaptions[currentCarouselCaptionIndex % 5])
$("#carousel-text").animate({
opacity: 1
}, 200);
});
}
}
function bindCarouselFunctions() {
$("#classroomredesign-carousel").on("slide.bs.carousel", function(e) {
cycleCarouselCaptions(e.direction);
});
}
function init() {
layoutButtonScrollMin = $("#layout-panel").offset().top - 250;
layoutButtonScrollMax = $("#layout-panel").offset().top + $("#layout-panel").height() / 3.0;
bindMouseFunctionsForLayoutButtons();
bindCarouselFunctions();
console.log("init");
var imageScrollDistance = 2500;
currentScrollTop = window.pageYOffset;
var windowHeight = window.innerHeight;
var windowWidth = window.innerWidth;
var layoutTop = $("#layout-panel").offset().top;
currentState = "title";
foodRedesignTop = $("#food_redesign").offset().top;
document.onscroll = function() {
var deltaY = window.pageYOffset - currentScrollTop;
currentScrollTop = window.pageYOffset;
if (!layoutButtonsActive && deltaY > 0 && currentScrollTop > layoutButtonScrollMin && currentState == "title") {
if (showLayoutButtons())
currentState = "layout";
} else if (layoutButtonsActive && deltaY < 0 && currentScrollTop < layoutButtonScrollMin && currentState == "layout") {
if (hideLayoutButtons())
currentState = "title";
} else if (layoutButtonsActive && deltaY > 0 && currentScrollTop > layoutButtonScrollMax && currentState == "layout") {
if (hideLayoutButtons())
currentState = "taxonomy";
} else if (!layoutButtonsActive && deltaY < 0 && currentScrollTop < layoutButtonScrollMax && currentState == "taxonomy") {
if (showLayoutButtons())
currentState = "layout";
} else if (deltaY > 0 && currentScrollTop > foodRedesignTop && currentState != "food_redesign") {
$("#food_redesign").css({
"position" : "fixed",
"top" : "0px"
});
currentState = "food_redesign";
$(".food_redesign_caption").show();
$("#food_redesign_caption-7").css({
top: "47%",
left: (windowWidth - $("#food_redesign_caption-7").width()) / 2
});
$("#food_redesign_caption-8").css({
top: "53%",
left: (windowWidth - $("#food_redesign_caption-8").width()) / 2
});
} else if (deltaY < 0 && currentScrollTop < foodRedesignTop && currentState == "food_redesign") {
$("#food_redesign").css({
"position" : "absolute",
"top" : "0px"
});
currentState = "taxonomy";
$(".food_redesign_caption").hide();
} else if (currentScrollTop > foodRedesignTop) {
var time = Math.min(1, (currentScrollTop - foodRedesignTop) / 5000);
var t1 = time >= 0.5 ? 1 : (time * 2);
var t2 = time < 0.5 ? 0 : ((time - 0.5) * 2);
$("#food_redesign_caption-7").css({
opacity: Math.min(1, t1)
});
$("#food_redesign_caption-8").css({
opacity: Math.min(1, t2)
});
$("#food_redesign_caption-1").css({
opacity: Math.min(1, t1 * 2),
left: (-10 + 54 * t1) + "%",
top: (45 - 52 * Math.pow(t2, 2)) + "%"
});
$("#food_redesign_caption-2").css({
opacity: Math.min(1, t1 * 2),
left: (-15 + 62 * Math.pow(t1, 1.5)) + "%",
top: (50 - 58 * Math.pow(t2, 1.5)) + "%"
});
$("#food_redesign_caption-3").css({
opacity: Math.min(1, t1 * 2),
left: (-20 + 63 * Math.pow(t1, 2)) + "%",
top: (55 - 72 * t2) + "%"
});
$("#food_redesign_caption-4").css({
opacity: Math.min(1, t1 * 2),
left: (105 - 57 * t1) + "%",
top: (45 - 72 * t2) + "%"
});
$("#food_redesign_caption-5").css({
opacity: Math.min(1, t1 * 2),
left: (110 - 59 * Math.pow(t1, 1.5)) + "%",
top: (50 - 68 * Math.pow(t2, 1.5)) + "%"
});
$("#food_redesign_caption-6").css({
opacity: Math.min(1, t1 * 2),
left: (115 - 61 * Math.pow(t1, 2)) + "%",
top: (55 - 70 * t2) + "%"
});
}
}
}