From 143b67bc308926438f1b8c6860fc44993de50a5b Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Fri, 13 Apr 2012 13:00:00 -0700 Subject: Removing extra width setter --- js/slides.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'js') diff --git a/js/slides.js b/js/slides.js index d1b094b..5363183 100644 --- a/js/slides.js +++ b/js/slides.js @@ -75,6 +75,33 @@ SlideDeck.prototype.onDomLoaded_ = function(e) { SlideDeck.prototype.addEventListeners_ = function() { document.addEventListener('keydown', this.onBodyKeyDown_.bind(this), false); window.addEventListener('popstate', this.onPopState_.bind(this), false); + + var slides = document.querySelector('slides'); + slides.addEventListener('slideenter', + this.handleSlideMovement_.bind(this), false); + slides.addEventListener('slideleave', + this.handleSlideMovement_.bind(this), false); +}; + +/** + * @private + * Callback to perform generic tasks on slideenter/slideleave events. + */ +SlideDeck.prototype.handleSlideMovement_ = function(e) { + var slide = e.target; + var gdbar = slide.querySelector('aside[is="x-gdbar"]'); + if (gdbar) { + if (e.type == 'slideenter') { + // Need slight delay here for case where you're on the current slide + // and the animation needs to run. This is because the web compontents + // polyfill fires on DOMContentLoaded (e.g. a race condition). + setTimeout(function() { + gdbar.classList.add('active'); + }, 5); + } else { + gdbar.classList.remove('active'); + } + } }; /** -- cgit v1.2.3