-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add a drag-features example #3048
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
Conversation
More specifically: handleDownEvent, handleDragEvent, handleMoveEvent, and handleUpEvent.
ol.Map#getTarget returns an element or a string, depending on what was passed to setTarget. This commit adds a getTargetElement method that always returns an Element.
Thanks for your comments @tsauerwein. They are addressed. |
handleDragEvent: app.Drag.prototype.handleDragEvent, | ||
handleMoveEvent: app.Drag.prototype.handleMoveEvent, | ||
handleUpEvent: app.Drag.prototype.handleUpEvent | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
ol.interaction.Pointer.call(this, app.Drag.prototype);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but with a typecast to make the compiler happy when we compile build/examples/all.combined.js.
This example also demonstrates how to implement a custom interaction that inherits from ol.interaction.Pointer.
I changed the implementation of |
I'll merge this tomorrow if there's no other feedback. Thanks! |
I appreciate the work you've done to make the library more extensible @elemoine, and I think it would be good to merge this. When we're all back, I would like to talk a bit more about it - I've got some questions, but nothing that should block. |
Thanks @tschaub. Looking forward to more discussions on this. |
This example is really neat! I'm going to implement this in a custom control I'm currently building. Thanks a lot for your work on this, @elemoine. A quick question: any reason why this was not made an official ol3 interaction ? More about this In the application I'm currently working on, I use ol3 as a sibling to my code. It also implements the exact same architecture (for custom controls, interactions, etc.) So, I'm going to implement the drag interaction as an 'official one' in my app, which means it wouldn't take too much efforts afterwards to port this to ol3 instead. If someone thinks that this interaction could/should go in ol3 src instead, then I'd be willing to make a PR for this. Thanks a lot |
There are many interactions we could add, and I am not sure where we should stop. To me the most important is make it possible to write custom interactions. |
I understand. In my case, I'm perfectly comfortable in customizing it as I please, so everything's fine the way it currently is. Thanks. |
This PR builds on #3032 to add a "drag-features" example. The example can be tested at http://erilem.net/ol3/drag-features/examples/drag-features.html.
The PR also
handleDownEvent
,handleDragEvent
,handleMoveEvent
andhandleUpEvent
options tool.interaction.Pointer
. In particular, these options make it possible to create "drag" type custom interactions.shouldStopEvent
. This is to avoid adding another option (shouldStopEvent
or similar) tool.interaction.Pointer
.ol.Map#getTargetElement
method.getTarget
may return anElement
or astring
, depending on what was passed tosetTarget
. UsinggetTargetElement
you are guaranteed to get anElement
instance.ol.geom.flat.transform.translate
andol.geom.Geometry#translate
for translating geometries.Please review.
Fixes #2947.