;(function(define){define(function(require,exports,module){ /*jshint esnext:true*/ 'use strict'; /** * Dependencies */ var component = require('gaia-component'); /** * Exports */ module.exports = component.register('gaia-toast', { created: function() { this.setupShadowRoot(); this.els = { inner: this.shadowRoot.querySelector('.inner'), bread: this.shadowRoot.querySelector('.bread') }; this.timeout = this.getAttribute('timeout'); }, show: function() { this.els.bread.removeEventListener('animationend', this.onAnimateOutEnd); clearTimeout(this.hideTimeout); this.els.inner.classList.add('visible'); var reflow = this.els.inner.offsetTop; this.els.bread.classList.remove('animate-out'); this.els.bread.classList.add('animate-in'); this.hideTimeout = setTimeout(this.hide.bind(this), this.timeout); }, hide: function() { var self = this; clearTimeout(this.hideTimeout); this.els.bread.classList.remove('animate-in'); this.els.bread.classList.add('animate-out'); this.els.bread.removeEventListener('animationend', this.onAnimateOutEnd); this.onAnimateOutEnd = function() { self.els.bread.removeEventListener('animationend', self.onAnimateOutEnd); self.els.bread.classList.remove('animate-out'); self.els.inner.classList.remove('visible'); }; this.els.bread.addEventListener('animationend', this.onAnimateOutEnd); }, animateOut: function() {}, attrs: { timeout: { get: function() { return this.getAttribute('timeout') || 1000; }, set: function(value) { var current = this.getAttribute('timeout'); if (current == value) { return; } else if (!value) { this.removeAttribute('timeout'); } else { this.setAttribute('timeout', value); } } } }, template: `