diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/slides.js | 27 |
1 files changed, 27 insertions, 0 deletions
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) { | |||
75 | SlideDeck.prototype.addEventListeners_ = function() { | 75 | SlideDeck.prototype.addEventListeners_ = function() { |
76 | document.addEventListener('keydown', this.onBodyKeyDown_.bind(this), false); | 76 | document.addEventListener('keydown', this.onBodyKeyDown_.bind(this), false); |
77 | window.addEventListener('popstate', this.onPopState_.bind(this), false); | 77 | window.addEventListener('popstate', this.onPopState_.bind(this), false); |
78 | |||
79 | var slides = document.querySelector('slides'); | ||
80 | slides.addEventListener('slideenter', | ||
81 | this.handleSlideMovement_.bind(this), false); | ||
82 | slides.addEventListener('slideleave', | ||
83 | this.handleSlideMovement_.bind(this), false); | ||
84 | }; | ||
85 | |||
86 | /** | ||
87 | * @private | ||
88 | * Callback to perform generic tasks on slideenter/slideleave events. | ||
89 | */ | ||
90 | SlideDeck.prototype.handleSlideMovement_ = function(e) { | ||
91 | var slide = e.target; | ||
92 | var gdbar = slide.querySelector('aside[is="x-gdbar"]'); | ||
93 | if (gdbar) { | ||
94 | if (e.type == 'slideenter') { | ||
95 | // Need slight delay here for case where you're on the current slide | ||
96 | // and the animation needs to run. This is because the web compontents | ||
97 | // polyfill fires on DOMContentLoaded (e.g. a race condition). | ||
98 | setTimeout(function() { | ||
99 | gdbar.classList.add('active'); | ||
100 | }, 5); | ||
101 | } else { | ||
102 | gdbar.classList.remove('active'); | ||
103 | } | ||
104 | } | ||
78 | }; | 105 | }; |
79 | 106 | ||
80 | /** | 107 | /** |