Skip to content

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

Merged
merged 7 commits into from
Dec 19, 2014
Merged

Add a drag-features example #3048

merged 7 commits into from
Dec 19, 2014

Conversation

elemoine
Copy link
Member

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

  • adds handleDownEvent, handleDragEvent, handleMoveEvent and handleUpEvent options to ol.interaction.Pointer. In particular, these options make it possible to create "drag" type custom interactions.
  • changes the default implementation of shouldStopEvent. This is to avoid adding another option (shouldStopEvent or similar) to ol.interaction.Pointer.
  • adds an ol.Map#getTargetElement method. getTarget may return an Element or a string, depending on what was passed to setTarget. Using getTargetElement you are guaranteed to get an Element instance.
  • adds ol.geom.flat.transform.translate and ol.geom.Geometry#translate for translating geometries.

Please review.

Fixes #2947.

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.
@elemoine
Copy link
Member Author

Thanks for your comments @tsauerwein. They are addressed.

handleDragEvent: app.Drag.prototype.handleDragEvent,
handleMoveEvent: app.Drag.prototype.handleMoveEvent,
handleUpEvent: app.Drag.prototype.handleUpEvent
});
Copy link
Member

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

?

Copy link
Member Author

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.
@elemoine
Copy link
Member Author

I changed the implementation of ol.geom.flat.transform.translate as we discussed. I think it looks better now. I also removed the changes I had to make to transform2D.

@elemoine
Copy link
Member Author

I'll merge this tomorrow if there's no other feedback. Thanks!

@tschaub
Copy link
Member

tschaub commented Dec 18, 2014

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.

@elemoine
Copy link
Member Author

Thanks @tschaub. Looking forward to more discussions on this.

elemoine pushed a commit that referenced this pull request Dec 19, 2014
@elemoine elemoine merged commit a24716a into openlayers:master Dec 19, 2014
@elemoine elemoine deleted the drag-features branch December 19, 2014 07:49
@adube
Copy link
Contributor

adube commented Feb 20, 2015

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

@elemoine
Copy link
Member Author

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.

@adube
Copy link
Contributor

adube commented Feb 23, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a drag feature interaction
3 participants