Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDrag (in useGesture) fires just a few times and lags #28

Open
KamilStehlicek opened this issue Mar 14, 2024 · 1 comment
Open

onDrag (in useGesture) fires just a few times and lags #28

KamilStehlicek opened this issue Mar 14, 2024 · 1 comment

Comments

@KamilStehlicek
Copy link

KamilStehlicek commented Mar 14, 2024

When I use onDrag like following:

useGesture({
  onDrag: dragHandler
}, {
  domTarget: image
})

with following handler:

const dragHandler = ({ movement: [x, y], dragging }) => {
  if(dragging) {
    console.log("moving")
    console.log({ x, y })
    imageConfiguration.value.top += y
    imageConfiguration.value.left += x
  }
}

the dragging event fires only about 2 to 4 times and doesnt continue.

For example when i use standart eventListener to the same element, the event fires for each pixel that I dragged. But here it completely lags and I cant use it.

Can someone help me with what am I doing wrong? Or do I misunderstand the usage?

For the whole picture, I use then the imageConfiguration to create style for the element I want to drag ->

const imageStyle = computed(() => {
  return {
    'top': imageConfiguration.value.top.toString() + 'px',
    'left': imageConfiguration.value.left.toString() + 'px',
  }
})
@KamilStehlicek
Copy link
Author

KamilStehlicek commented Mar 14, 2024

Update: the example used works, but under verystrange conditions. It works, if I double tap the wanted object and I have to literally push the trackpad. I cannot just double-tap it...

And what is also strange - demo "MultiGesture.vue" works for me just fine without any mistakes...but the code is same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant