diff --git a/lib/assets/javascripts/attentive.js.coffee b/lib/assets/javascripts/attentive.js.coffee index 8843230..e288e09 100644 --- a/lib/assets/javascripts/attentive.js.coffee +++ b/lib/assets/javascripts/attentive.js.coffee @@ -109,8 +109,6 @@ class this.Attentive @_slidesViewer ||= document.querySelector(@identifier) start: -> - @bodyClassList().add('loading') - if !this.isFile() window.addEventListener('popstate', @handlePopState, false) @@ -118,7 +116,20 @@ class this.Attentive document.addEventListener('keydown', @handleKeyDown, false) window.addEventListener('resize', _.throttle(@calculate, 500), false) - this.advanceTo(this.slideFromLocation()) + imageWait = null + imageWait = => + wait = false + + for slide in @allSlides() + for img in slide.dom.getElementsByTagName('img') + wait = true if !img.complete + + if wait + setTimeout(imageWait, 100) + else + this.advanceTo(this.slideFromLocation()) + + imageWait() slideFromLocation: -> value = if this.isFile() @@ -197,4 +208,5 @@ class this.Attentive @bodyClassList().remove('loading') @initialRender = false - + @currentWindowHeight = null + this.calculate() diff --git a/lib/assets/stylesheets/attentive.css.scss b/lib/assets/stylesheets/attentive.css.scss index f276904..a7836a9 100644 --- a/lib/assets/stylesheets/attentive.css.scss +++ b/lib/assets/stylesheets/attentive.css.scss @@ -33,8 +33,8 @@ body, html { } body.loading { - #slides-container { - opacity: 0; + .slide { + opacity: 0 !important; } } diff --git a/views/layout.haml b/views/layout.haml index bc8d408..724e235 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -6,6 +6,6 @@ %link{:rel => 'stylesheet', :href => 'assets/application.css', :type => 'text/css'}/ %style{:type => 'text/css'}= Pygments.css = haml :"_header" - %body + %body.loading = yield