v-idle
v-idle copied to clipboard
Emit Vue event when a new event is received
It'd be great if we can listen to the events registered in the component here. In that way, we can do certain actions when the values are restarted eg. close information modals, etc.
Maybe something like this:
window.addEventListener(this.events[i], function() {
this.$emit('event-triggered', this.events[i]);
this.clearTimer();
})
Then we can do something like this:
<v-idle @event-triggered="closeModal($event)"/>
......
closeModal(event) {
if (event === 'mousemove') {
// execute my actions (close information modal)
}
}
@malekim Is there any other way to achieve the same with this library?
Looks reasonable, I added this to my todo list.
@malekim thanks! That'd be great because I was thinking of automatically hiding the countdown modal whenever you move the mouse(no need to click over a button, if you're already interacting with the page I'm assuming you're back). I can try to open a PR this weekend :)
@roberto910907 You can now do this using refresh callback
<v-idle @refresh="onrefresh" />
function onrefresh() { console.log("user did something") }
I extended refresh event with additional data. There is an example in the documentation.