From 190e24251c17733eff8fc1b11a077ca2da4b6c4f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 11 Dec 2015 04:24:13 -0600 Subject: rebuild --- StoneIsland/www/js/lib/products/ClosedStoreView.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'StoneIsland/www/js/lib/products') diff --git a/StoneIsland/www/js/lib/products/ClosedStoreView.js b/StoneIsland/www/js/lib/products/ClosedStoreView.js index 5f8c1e84..6f7b8486 100755 --- a/StoneIsland/www/js/lib/products/ClosedStoreView.js +++ b/StoneIsland/www/js/lib/products/ClosedStoreView.js @@ -12,6 +12,7 @@ var ClosedStoreView = View.extend({ timeout: -1, images: null, + images_loaded: {}, initialize: function(){ this.loader = new Loader () @@ -21,7 +22,6 @@ var ClosedStoreView = View.extend({ document.body.className = "closed" this.animate() app.footer.hide() - console.log(this) if (this.storeOpenDate) { var date = moment(this.storeOpenDate).format("MM/DD") console.log(date) @@ -38,15 +38,27 @@ var ClosedStoreView = View.extend({ animate: function(){ this.timeout = setTimeout(this.animate.bind(this), this.delay) + this.next() + }, + + next: function(){ if (! this.images) return var url = choice(this.images) - this.loader.preloadImage(url, function(img){ - this.el.style.backgroundImage = 'url(' + img.src + ')' - }.bind(this)) + + if (this.images_loaded[url]) { + this.el.style.backgroundImage = 'url(' + url + ')' + } + else { + this.loader.preloadImage(url, function(img){ + this.el.style.backgroundImage = 'url(' + url + ')' + this.images_loaded[url] = true + }.bind(this)) + } }, populate: function(data){ this.images = data.map(function(img){ return img.uri }) + this.next() }, website_link: function(){ -- cgit v1.2.3-70-g09d2