Cleanup
This commit is contained in:
parent
e21e517371
commit
53cd3f62e2
3 changed files with 10 additions and 18 deletions
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ html, body, img, #container {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
#control {
|
||||
#play {
|
||||
visibility: hidden;
|
||||
display: inline-block;
|
||||
border-radius: 10px;
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue