1
0
Fork 0
playafri.ca/assets/scripts/africa.js

43 lines
847 B
JavaScript
Raw Normal View History

2014-09-25 15:38:49 -04:00
var sound = null;
2014-09-26 10:06:40 -04:00
var play = document.getElementById('play');
2014-09-25 13:28:27 -04:00
var background = document.getElementById('background');
function load() {
makeItRain();
2014-09-25 15:38:49 -04:00
makeItPlay();
}
function makeItPlay() {
sound = new Howl({
urls: ['assets/audio/africa.ogg', 'assets/audio/africa.m4a'],
autoplay: true,
2014-09-26 09:55:44 -04:00
loop: true,
onplay: function() {
2014-09-26 10:18:14 -04:00
play.style.visibility = 'hidden';
2014-09-26 09:55:44 -04:00
}
2014-09-25 15:38:49 -04:00
});
2014-09-26 10:06:40 -04:00
2014-09-25 15:38:49 -04:00
setTimeout(enableToggle, 2500);
2014-09-25 13:28:27 -04:00
}
2014-09-25 10:38:34 -04:00
2014-09-25 13:28:27 -04:00
function makeItRain() {
background.onload = function() {
2014-09-25 10:38:34 -04:00
var engine = new RainyDay({
image: this
});
engine.rain([ [3, 2, 2] ], 100);
};
2014-09-26 10:06:40 -04:00
background.src = 'assets/images/africa.png';
2014-09-25 13:28:27 -04:00
background.crossOrigin = 'anonymous';
2014-09-25 10:38:34 -04:00
}
2014-09-26 10:18:14 -04:00
function playSound() {
2014-09-26 10:06:40 -04:00
sound.play();
}
2014-09-25 15:38:49 -04:00
var enableToggle = function() {
if(0 === sound.pos()) {
2014-09-26 10:06:40 -04:00
play.style.visibility = 'visible';
2014-09-25 13:40:32 -04:00
}
}