mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-03-16 22:10:27 +00:00
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:
commit
034bf10565
1 changed files with 14 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue