This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
151 lines (135 loc) · 4.29 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
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
'use strict';
var setbg = function (el, imgwidth, imgheight) {
if ($(window).width() <= 1280) {
imgwidth = imgwidth / 4 * 3;
imgheight = imgheight / 4 * 3;
}
var centerx = $(el).width() / 2;
var centery = $(el).height() / 2;
var posx = centerx - (imgwidth / 2);
var posy = centery - (imgheight / 2);
$(el).css('background-position', posx + 'px ' + posy + 'px');
}
var main = function () {
$('#welkom h1').remove();
$('#welkom h2').remove();
}
$(document).ready(function (event) {
main();
setbg($('section#welkom'), 1101, 950);
setbg($('section div#spark'), 1280, 800);
setbg($('section div#logo'), 800, 169);
});
$(window).scroll(function () {
var welkompos = $('#welkom').height();
var themapos = 2 * welkompos;
var programmapos = $('#programma').height() + themapos;
var etiquettepos = $('#etiquette').height() + programmapos;
var pos = $(window).scrollTop();
if (pos >= themapos) {
$('#m').fadeIn();
} else {
$('#m').fadeOut();
}
if (pos < welkompos) {
$('nav li a').removeClass('selected');
$('nav li:first-child a').addClass('selected');
} else if (pos >= welkompos && pos < themapos) {
$('nav li a').removeClass('selected');
$('nav li:nth-child(2) a').addClass('selected');
} else if (pos >= themapos && pos < programmapos) {
$('nav li a').removeClass('selected');
$('nav li:nth-child(3) a').addClass('selected');
} else if (pos >= programmapos && pos < etiquettepos) {
$('nav li a').removeClass('selected');
$('nav li:nth-child(4) a').addClass('selected');
} else if (pos >= etiquettepos) {
$('nav li a').removeClass('selected');
$('nav li:nth-child(5) a').addClass('selected');
}
})
var parallax = function (el, event, imgwidth, imgheight, delay) {
if ($(window).width() <= 1280) {
imgwidth = imgwidth / 4 * 3;
imgheight = imgheight / 4 * 3;
}
if (imgwidth === 0 && imgheight === 0) {
imgwidth = $(el).width() * 1.05;
imgheight = $(el).height() * 0.85;
}
var x = event.pageX;
var y = event.pageY;
var centerx = $(el).width() / 2;
var centery = $(el).height() / 2;
var posx = centerx - (imgwidth / 2) - (x - centerx) * delay;
var posy = centery - (imgheight / 2) - (y - centery) * delay;
$(el).css('background-position', posx + 'px ' + posy + 'px');
}
$('#welkom').mousemove(function (event) {
parallax(this, event, 1101, 950, 0.01);
});
$('#spark').mousemove(function (event) {
parallax(this, event, 1280, 800, 0.06);
});
$('#logo').mousemove(function (event) {
parallax(this, event, 800, 169, 0.02);
});
$('#commissie').mousemove(function (event) {
parallax(this, event, 0, 0, 0.02);
})
$('nav a').click(function (event) {
event.preventDefault();
var el = $(this).attr('href');
$('html, body').animate({
scrollTop: $(el).offset().top
}, 800);
});
$('#m').click(function (event) {
event.preventDefault();
var el = $(this).parent().attr('href');
$('html, body').animate({
scrollTop: $(el).offset().top
}, 800);
});
$('nav a[href="#video"]').click(function (event) {
player.playVideo();
});
/**
* Video player
*/
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
videoId: 'kWs9rxfamyo',
playerVars: {
'controls': 0,
'modestbranding': 1,
'showinfo': 0
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
player.setPlaybackQuality('hd720');
}
function onPlayerStateChange(event) {
var welkompos = $('#welkom').height();
var programmapos = $('#programma').height() + 2 * welkompos;
if (event.data === YT.PlayerState.ENDED && $(window).scrollTop() < programmapos) {
$('html, body').animate({
scrollTop: $('#programma').offset().top
}, 800);
}
}
function stopVideo() {
player.stopVideo();
}