Comments (5)
I am liking it, but it seems somewhat complex that you need to check that arg.layer !== this
, though I don't claim to understand the nuance required here. Also, could you just pass the string "pan"
as the first argument to on()
? Seems that would be more jQuery-like.
from geojs.
On Fri, Mar 14, 2014 at 8:36 AM, Jonathan Beezley
[email protected]:
In this commit 73257427325742,
I have add a jQuery like interface for binding and triggering events. The
idea is that classes will interact with each other like this (for example
panning in the layer class)this.map().on(geo.event.pan, function (arg) {
if (arg.layer !== this) {
this.trigger(geo.event.pan, arg);
}});this.on(geo.event.pan, function (arg) {// layer specific implementation here
this.map().trigger(geo.event.pan, arg);});
The only problem is that this kind of propagation through the tree will
have to be coded for every event type. I'm wondering if it might be useful
to add standard parent/children attributes to the object, then the mapwould copy its
layers into children and layer would put the map in parent and the
renderer in children, etc. This way we could implement this generically
in geo.object. Also, we would want to bind the triggerer to this in the
handler to prevent circular propagation. What does everyone think?I don't have a problem with adding this if . Maybe it should be a subclass
of object though, so only those classes that need this parent/child get it?
from geojs.
The difference between this and jQuery is that we need to propagate events both up and down the tree, so we need a mechanism for preventing circular propagation. I'm up to suggestions on how to do this. Also, geo.event.pan is defined here. It is just a string, but I think the idea is to support something like namespacing in the events.
from geojs.
Okay, here is the latest interface 03e03a2.
I changed the routing as follows:
- An event is triggered on an object.
- If the object has a parent and the parent did not trigger the event, it propagates the event up the tree and returns (not calling its handlers).
- It calls all of its own handlers.
- It triggers the event on all of its children.
It seems we also need a mechanism for preventing propagation. Maybe a stopPropagation
callback as an extra argument to the handler?
@cjh1 The object defaults to no parents or children, so everything will work without a tree structure; however, I'm not opposed to moving this to a subclass.
from geojs.
@jbeezley I like the idea of making it generic. So I guess this could be applied to features as well? Any thought on that? Also, I think moving the parent / child to to something like sceneObject (or something similar) would be appropriate in that case; map, layer and renderer could use that as the base class.
from geojs.
Related Issues (20)
- Use semantic-release to update the CHANGELOG HOT 2
- Potential new tile source
- Tiled pixelmaps HOT 3
- Remove or update vtkjs renderer HOT 1
- Update tooling HOT 1
- Examples fail to build HOT 3
- TrackFeature futureStyle does not override style HOT 2
- Broken links to source code of examples HOT 2
- getError performance issue HOT 5
- Extreme zoom levels HOT 1
- Changing map gcs should cause all coordinates to recompute
- Utility function for placing subimages on maps
- was there any way to show image(png or svg) on pointFeature or markerFeature? HOT 1
- Better marker hit tests
- How to use geo.js to get tiles from whole slide image without a web service, for example in PyQt HOT 7
- zoom in zoom out has delay to wheel event HOT 2
- Annotation events
- Change tile layer url doesn't always discard all old tiles HOT 1
- is it possible to show magnification in slider widget, how to do that HOT 2
- Remove stamen tiles HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geojs.