1
0
Fork 0
This commit is contained in:
Andrew Tomaka 2014-09-26 10:06:40 -04:00
parent e21e517371
commit 53cd3f62e2
3 changed files with 10 additions and 18 deletions

View file

@ -1,18 +1,7 @@
var sound = null;
var playing = true;
var control = document.getElementById('control');
var play = document.getElementById('play');
var background = document.getElementById('background');
function toggle() {
if(playing) {
sound.pause();
playing = false;
} else {
sound.play();
playing = true;
}
}
function load() {
makeItRain();
makeItPlay();
@ -27,6 +16,7 @@ function makeItPlay() {
control.style.visibility = 'hidden';
}
});
setTimeout(enableToggle, 2500);
}
@ -37,14 +27,16 @@ function makeItRain() {
});
engine.rain([ [3, 2, 2] ], 100);
};
background.src = 'assets/images/africa.png';
background.src = 'assets/images/africa.png';
background.crossOrigin = 'anonymous';
}
function play() {
sound.play();
}
var enableToggle = function() {
if(0 === sound.pos()) {
playing = false;
control.className = 'icon-play';
control.style.visibility = 'visible';
play.style.visibility = 'visible';
}
}

View file

@ -15,7 +15,7 @@ html, body, img, #container {
text-align: center;
}
#control {
#play {
visibility: hidden;
display: inline-block;
border-radius: 10px;

View file

@ -13,7 +13,7 @@
<img id="background" src="" />
<div id="container">
<i id="control" class="icon-play" onclick="javascript:toggle();"></i>
<i id="play" class="icon-play" onclick="javascript:play();"></i>
</div>
<script>