-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Select Mode easier to extend #168
Comments
Would it be easier if we provided a way to disable selection/midpoints whilst dragging in the builtin in Select mode? |
Hi, thanks @JamesLMilner that could be a nice thing to have, but actually I was able to find a workaround to extend the mode, and now I'm not only doing the removal of selection and midpoints, I'm addressing some other behaviors. What I did was to extend the select mode and cast Here's an illustrative example:
I think the best approach on my side is to have everything as "vanilla" as possible so let me list the things im doing in this extended class aside from the removal of the selection/mid points for you to know, and maybe suggest some workaround and avoid having this extended class. 1- Im not setting 'selecting' state on start.The problem here was that sometimes the user was selecting features rapidly, which would lead to the PointerUp being sufficiently far way from the PointerDown event to be consider as click instead of drag. So basically the user (wanting to select a feature) unintentionally drag a little bit. This would lead to the user to think that the tool was not working. To fix this I first set Then i changed start method to NOT set 'selecting' state. Then i added a new method in the extendedSelectMode, I have a listener for 'PointerDown' and that listener would call this method which looks like this:
As you can see all this method do is setSelecting state ONLY if the pointerDown event could be interpreted as drag. I also had to change
What i accomplish with this is that I can drag inside a feature a little bit (30 pixels max) and still select the feature i want. This without affecting the drag behavior anywhere else, meaning when i want to drag the map it wont take 30 pixels for the map to start moving it'll start moving right away. 2- override onMouseMoveIf the user is near a selection point i change the cursor style to 'pointer', to let the user know if he clicks at that moment it will be affecting that selection point and not the whole feature.
3- Public
|
Im trying to create my own implementation of select mode (Im basically removing all mid and selection points ONLY while dragging the features, so this way those layers wont get updated 60 times per second, to improve performance in maplibre) , I will reuse most of the methods and properties that are already in the mode i will only override some of them.
So the proposal is to make all properties and methods of select mode
protected
instead ofprivate
, so this way i can make references to those in my own subclass.I realized that this way is a perfect fit for my implementation of the tool, and discovered it by browsing the documentation where its mentioned that you can create your own select method.
Also while starting this implementation i realized i will be using an slightly changed version of
src/modes/select/behaviors/drag-coordinate.behavior.ts
andsrc/modes/select/behaviors/selection-point.behavior.ts
again only changing a few or a single method of the classes so it would be nice to have a way to import those classes from the Terra draw API and be able to call its method from a subclass.Thanks for the suggestion of creating your own implementation of the mode, it really opened my mind.
The text was updated successfully, but these errors were encountered: