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

Regions "regions-double-clicked" event does not trigger on mobile #3927

Open
eliaszech opened this issue Nov 4, 2024 · 1 comment
Open

Comments

@eliaszech
Copy link

Bug description

When using regions:
Regions "regions-double-clicked" event does not trigger on mobile

Environment

  • Browser: Internet on Android, Edge on Android

Minimal code snippet

regions.on('region-double-clicked', function(region, e) {
    e.stopPropagation()
    axios.post('/api/annotations/' + region.id + '/delete');
    region.remove();
})

Expected result

Event should be firing on double tap on region

Obtained result

Event not firing on double tap on region

@katspaugh
Copy link
Owner

This event is using the native dblclick DOM event which sadly isn't supported on touch devices.

We can detect double taps manually like this:

let lastTap = 0
element.addEventListener('touchend', (e) => {
  const tapGap = Date.now() - lastTap
  if (tapGap < 300 && tapGap > 0) { // Detect double-tap (within 300ms)
    this.emit('dblclick', e)
  }
  lastTap = currentTime
})

Pull requests are welcome!

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

No branches or pull requests

2 participants