summaryrefslogtreecommitdiff
path: root/public/js/lib/bg.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/lib/bg.js')
-rw-r--r--public/js/lib/bg.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/public/js/lib/bg.js b/public/js/lib/bg.js
index 2bcd284..4d6dfb8 100644
--- a/public/js/lib/bg.js
+++ b/public/js/lib/bg.js
@@ -1,11 +1,20 @@
var bg = (function(){
var bg = {}
+ var transitioning = false
bg.el = document.getElementById("bg")
bg.change = function(picture){
+ bg.picture = picture
+
var img = new Image ()
img.src = picture.url
+
+ transitioning = true
+ if (transitioning) {
+ bg.update()
+ return
+ }
oktween.add({
obj: bg.el.style,
from: { opacity: 1 },
@@ -13,16 +22,22 @@ var bg = (function(){
easing: "circ_in",
duration: 200,
finished: function(){
- bg.el.style.backgroundImage = "url(" + picture.url + ")"
- bg.el.className = picture.tile ? "tile" : ""
+ bg.update()
}
}).then({
delay: 500,
to: { opacity: 1 },
easing: "circ_in",
duration: 200,
+ finished: function(){
+ transitioning = false
+ }
})
}
+ bg.update = function(){
+ bg.el.style.backgroundImage = "url(" + bg.picture.url + ")"
+ bg.el.className = bg.picture.tile ? "tile" : ""
+ }
return bg
})() \ No newline at end of file