diff --git a/example/routers/dialog.vue b/example/routers/dialog.vue index 31bf643e..2270075a 100644 --- a/example/routers/dialog.vue +++ b/example/routers/dialog.vue @@ -1,113 +1,112 @@ diff --git a/src/components/dialog/src/notify/index.js b/src/components/dialog/src/notify/index.js index 0b2d52af..59c39572 100644 --- a/src/components/dialog/src/notify/index.js +++ b/src/components/dialog/src/notify/index.js @@ -6,6 +6,11 @@ const instance = new NotifyConstructor({ el: document.createElement('div') }); +const notifyClicked = function () { + clearTimeout(timer); + instance.clickNotify(); +} + let timer = null; let lock = false; @@ -14,6 +19,7 @@ NotifyConstructor.prototype.closeNotify = function () { setTimeout(() => { const el = instance.$el; + el.removeEventListener("click", notifyClicked); el.parentNode && el.parentNode.removeChild(el); lock = false; }, 150); @@ -21,21 +27,24 @@ NotifyConstructor.prototype.closeNotify = function () { typeof this.callback === 'function' && this.callback(); }; +NotifyConstructor.prototype.clickNotify = function () { + typeof this.clickCallback === 'function' && this.clickCallback(); + instance.closeNotify(); +}; + const Notify = (options = {}) => { instance.classes = ''; instance.mes = options.mes; instance.timeout = ~~options.timeout || 5000; instance.callback = options.callback; + instance.clickCallback = options.clickCallback; - if (lock)return; + if (lock) return; lock = true; document.body.appendChild(instance.$el); - instance.$el.addEventListener('click', () => { - clearTimeout(timer); - instance.closeNotify(); - }); + instance.$el.addEventListener('click', notifyClicked); timer = setTimeout(() => { clearTimeout(timer); diff --git a/src/components/dialog/src/notify/notify.vue b/src/components/dialog/src/notify/notify.vue index 32237a0e..f946fc00 100644 --- a/src/components/dialog/src/notify/notify.vue +++ b/src/components/dialog/src/notify/notify.vue @@ -12,7 +12,8 @@ props: { mes: String, timeout: Number, - callback: Function + callback: Function, + clickCallback: Function } }