It depends what your custom element looks like. With your template you could just put @dragover=${this.dragEnter}
. However, if you want this to apply to your entire custom element and not just the button you can do something like this:
connectedCallback() {
super.connectedCallback();
this.addEventListener('dragover', this.dragEnter);
}
If you do not have custom element and just use lit-html by itself you have to put your event handlers dragEnter(e)
and dragLeave(e)
into the template like so: @dragover=${this.dragEnter}
You need to add the class with classList.add
in dragEnter and remove it in dragLeave. In the future you maybe can use classMap
directive in lit-html, however there is nothing wrong with just using classList
. I would stick with just using classList. In a very distant future css might also have a selector for it: Is there a CSS ":drop-hover" pseudo-class?