From 57320b04c6e40322507ade1dce1ba5490ebc0c2c Mon Sep 17 00:00:00 2001 From: Deema Yvanow Date: Mon, 1 Jun 2015 18:58:24 +0300 Subject: [PATCH 1/2] Append element on show instead of on init. Related to https://github.com/component/dialog/issues/21 --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f4f1922..cc35717 100644 --- a/index.js +++ b/index.js @@ -53,7 +53,6 @@ function Overlay(options) { this.target = options.target || document.body; this.closable = options.closable; this.el = domify(tmpl); - this.target.appendChild(this.el); if (this.closable) { event.bind(this.el, 'click', this.hide.bind(this)); classes(this.el).add('closable'); @@ -76,8 +75,16 @@ Emitter(Overlay.prototype); */ Overlay.prototype.show = function(){ + var self = this; + this.emit('show'); - classes(this.el).remove('hidden'); + this.target.appendChild(this.el); + + //class removed in a timeout to save animation + setTimeout( function () { + classes(self.el).remove('hidden'); + }); + return this; }; From bd2c2fcb4dbde6c6f56b467295048d4ce161442b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 1 Jun 2015 20:35:37 +0300 Subject: [PATCH 2/2] Remove whitespaces --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index cc35717..28f6e6f 100644 --- a/index.js +++ b/index.js @@ -76,15 +76,15 @@ Emitter(Overlay.prototype); Overlay.prototype.show = function(){ var self = this; - + this.emit('show'); this.target.appendChild(this.el); - + //class removed in a timeout to save animation setTimeout( function () { classes(self.el).remove('hidden'); }); - + return this; };