ngx-drag-to-select icon indicating copy to clipboard operation
ngx-drag-to-select copied to clipboard

[Question] Trigger drag selection based on pressed key

Open GRX opened this issue 4 years ago • 2 comments

Hi,

I'd like to know 2 things, 1; Is it possible to only initiate the drag select when (for ex;) the meta key is pressed? 2; Since nested components cannot be grabbed with a dragged selection, is it possible to get the start/end coordinates of the mouse when a selection has been made? (for ex; x10,y10 -> x15,y30)

GRX avatar Jun 07 '21 12:06 GRX

Hey! To both of your points:

1: No, this is unfortunately not possible but can easily be added. I am happy to accept a PR for this to make it configurable.

2: You could get hold of the selectItem instance you're interested in and call getBoundingClientRect which will give you the coordinates of that single item if that's any helpful. But I think we want to tackle the nested component use case in general. If you wanna help, I'd be down to assist you and discuss possible solutions.

d3lm avatar Jun 19 '21 12:06 d3lm

Hi, sorry to take me this long to come back to you, the project I've been working on kind of died but I'm trying to revive it.

For point 1: frankly, I don't think I'm skilled enough to write such implementation. For point 2: I sadly can't getBoundClientRect from a selected item, because the items that I need are in a nested component. But I wrote a basic function that can get the right elements based on starting/ending XY (pixel)coordinates.

If I can get just the XY starting positions from the bounding box after dragging, I'll be forever grateful :)

GRX avatar Aug 26 '22 23:08 GRX