Reply
Highlighted
Member
Posts: 1
Registered: ‎01-24-2020

How to detect a double click between list items for inserting an item in that position/gap?

I want to be able to double click on the space between list items in an unordered list and then display an input for inserting an item between in the position where clicked. I've placed a double click handler on the unordered list and can detect the click fine of course.

I'm at a loss for how to easily detect the position (eg: User clicked in the gap after the Nth list item). Since the handler is on the parent above the list items the target doesn't provide information of use. I assume I'll have to get offset coordinates of the click and try to calculate which item the click's coordinates fall after.

I assume this isn't that uncommon of a thing but after trying dozens of search queries I've been unable to find relevant examples on Stackoverflow or anywhere. Can someone point me in the right direction? Thanks!