d3lm / ngx-drag-to-select

A lightweight, fast, configurable and reactive drag-to-select component for Angular 10 and beyond
https://www.npmjs.com/package/ngx-drag-to-select
MIT License
293 stars 64 forks source link

[Question] Trigger drag selection based on pressed key #128

Open GRX opened 3 years ago

GRX commented 3 years ago

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)

d3lm commented 3 years ago

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.

GRX commented 2 years ago

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 :)