question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get $event on drag-enter/drag-leave

See original GitHub issue

I am having an issue grabbing the event from these handlers. They fire okay but I am not sure how to get the event.

@drag-enter="onDragEnter($event)"

function onDragEnter(e) {
   console.log(e) //returns undefined
}

I’ve also tried adding vanilla events and they don’t seem to work. Even a click handler does not work. Is there a way I can get the event from those two drag events?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
zerosymcommented, Aug 25, 2018

@chrisdel101 drag-enter & drag-leave events don’t pass any parameters to handlers.

As for click handlers and other browser implemented events you can append .native to the event name:

@click.native="onClickHandler($event)"

0reactions
zerosymcommented, Sep 6, 2018

@krsyoung For your case that’s what I would do too.

My first syntax only works if you have split the container into its own component.

For example, instead of:

<template>
  <container v-for="i in items" ...>
</template>

You would need to do

<template>
  <my-component v-for="item in items" :item=item :key="item.id">
</template>

Where my-component is:

<template>
  <container @drag-enter="onDragEnter">
</template>

<script>
{
  props: ['item',],
  methods: {
    onDragEnter() {
      console.log(this.item.id)
    },
  },
}
</script>
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTMLElement: dragleave event - Web APIs | MDN
The dragleave event is fired when a dragged element or text selection leaves a valid drop target.
Read more >
HTML5 dragleave fired when hovering a child element
Basically, it involves identifying and ignoring dragleave events which occur when dragging over child elements. Because the dragenter event is fired on child ......
Read more >
ondragleave Event - W3Schools
The ondragleave event occurs when a draggable element or text selection leaves a valid drop target. ... Get the dragged data with the...
Read more >
Control.DragLeave Event (System.Windows.Forms)
The DragLeave event is raised when the user drags the cursor out of the control or the user cancels the current drag-and-drop operation....
Read more >
Active States with Drag Enter and Leave Events in JavaScript
For this, we're going to simply add an active class to the draggable area. For this, we'll need to hook into the dragenter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found