v-idle icon indicating copy to clipboard operation
v-idle copied to clipboard

Emit Vue event when a new event is received

Open roberto910907 opened this issue 2 years ago • 2 comments

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?

roberto910907 avatar Nov 05 '21 17:11 roberto910907

Looks reasonable, I added this to my todo list.

malekim avatar Jan 20 '22 08:01 malekim

@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 avatar Jan 20 '22 13:01 roberto910907

@roberto910907 You can now do this using refresh callback

<v-idle @refresh="onrefresh" />

function onrefresh() { console.log("user did something") }

deidyomega avatar Feb 14 '24 14:02 deidyomega

I extended refresh event with additional data. There is an example in the documentation.

malekim avatar Feb 18 '24 22:02 malekim