Merge remote-tracking branch 'origin/develop' into improvt branch --set-upstream-to=<remote>/<branch> improvement/mdListement/mdList

* origin/develop:
  pause snackbar timeout on hover (#434)
This commit is contained in:
Marcos Moura 2017-02-07 00:27:32 -02:00
commit 034bf10565

View file

@ -1,5 +1,5 @@
<template>
<div class="md-snackbar" :class="[themeClass, classes]" :id="snackbarId">
<div class="md-snackbar" :class="[themeClass, classes]" :id="snackbarId" @mouseenter="pauseTimeout" @mouseleave="resumeTimeout">
<div class="md-snackbar-container" ref="container">
<div class="md-snackbar-content">
<slot></slot>
@ -89,6 +89,7 @@
this.active = true;
this.$emit('open');
this.closeTimeout = window.setTimeout(this.close, this.mdDuration);
this.timeoutStartedAt = Date.now();
},
close() {
if (this.$refs.container) {
@ -103,13 +104,25 @@
this.$refs.container.removeEventListener(transitionEndEventName, removeElement);
this.$refs.container.addEventListener(transitionEndEventName, removeElement);
window.clearTimeout(this.closeTimeout);
this.pendingDuration = this.mdDuration;
}
},
pauseTimeout() {
this.pendingDuration = this.pendingDuration - (Date.now() - this.timeoutStartedAt);
this.timeoutStartedAt = 0;
window.clearTimeout(this.closeTimeout);
},
resumeTimeout() {
this.timeoutStartedAt = Date.now();
this.closeTimeout = window.setTimeout(this.close, this.pendingDuration);
}
},
mounted() {
this.$nextTick(() => {
this.snackbarElement = this.$el;
this.snackbarElement.parentNode.removeChild(this.snackbarElement);
this.timeoutStartedAt = 0;
this.pendingDuration = this.mdDuration;
});
},
beforeDestroy() {