vueuse / gesture

🕹 Vue Composables making your app interactive
https://gesture.vueuse.org
MIT License
353 stars 18 forks source link

Expose domElement in options #26

Open IlyaSemenov opened 7 months ago

IlyaSemenov commented 7 months ago

I would like to be able to access the original domElement that the handler has been attached to inside gesture callbacks.

The use case would be (simplified code):

<script setup>
// Quick drag-to-scroll implementation
function handleDrag({ domElement, delta: [x, y] }) {
  domElement.scrollBy(-x, -y)
}
</script>

<template>
  <div v-drag="handleDrag">
    <div>child</div>
    <div>child</div>
  </div>
</template>

I realize I can work around this with an additional ref or even with a custom directive (as I did), my point here being reducing boilerplate for simpler ad-hoc code.