Ver código fonte

Merge pull request #804 from B1anker/master

Message, Notification: fix transitionend bug
杨奕 8 anos atrás
pai
commit
bd0ee6b270
2 arquivos alterados com 16 adições e 10 exclusões
  1. 8 5
      packages/message/src/main.vue
  2. 8 5
      packages/notification/src/main.vue

+ 8 - 5
packages/message/src/main.vue

@@ -35,15 +35,18 @@
       closed(newVal) {
         if (newVal) {
           this.visible = false;
-          this.$el.addEventListener('transitionend', () => {
-            this.$destroy(true);
-            this.$el.parentNode.removeChild(this.$el);
-          });
+          this.$el.addEventListener('transitionend', this.destroyElement);
         }
       }
     },
 
     methods: {
+      destroyElement() {
+        this.$el.removeEventListener('transitionend', this.destroyElement);
+        this.$destroy(true);
+        this.$el.parentNode.removeChild(this.$el);
+      },
+
       handleClose() {
         this.closed = true;
         if (typeof this.onClose === 'function') {
@@ -70,4 +73,4 @@
       this.startTimer();
     }
   };
-</script>
+</script>

+ 8 - 5
packages/notification/src/main.vue

@@ -44,15 +44,18 @@
       closed(newVal) {
         if (newVal) {
           this.visible = false;
-          this.$el.addEventListener('transitionend', () => {
-            this.$destroy(true);
-            this.$el.parentNode.removeChild(this.$el);
-          });
+          this.$el.addEventListener('transitionend', this.destroyElement);
         }
       }
     },
 
     methods: {
+      destroyElement() {
+        this.$el.removeEventListener('transitionend', this.destroyElement);
+        this.$destroy(true);
+        this.$el.parentNode.removeChild(this.$el);
+      },
+
       handleClose() {
         this.closed = true;
         if (typeof this.onClose === 'function') {
@@ -85,4 +88,4 @@
       }
     }
   };
-</script>
+</script>