Skip to content
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

Set listening automatically to true/false #483

Closed
sendel opened this issue Jun 3, 2013 · 4 comments
Closed

Set listening automatically to true/false #483

sendel opened this issue Jun 3, 2013 · 4 comments

Comments

@sendel
Copy link

sendel commented Jun 3, 2013

When layer have many small Shapes KJS 4.5.2 down speed. If this, try set {listening: false} on Shape.

@atomictag
Copy link

I assume listening:false prevents the hitCanvas from being updated, which can be quite a performance saving in some cases (especially if you are not drawing simple primitives). By default I tend to set listening:false to all nodes unless they really need to handle events. It kinda feels like mouse/touch event listening behaviour could be defined in Kinetic the other way around: disabled by default and activated on the nodes that require user interaction (IIRC that's kinda what EaselJS does).

@ericdrowell
Copy link
Owner

precisely, I do have plans to auto toggle the listening property based on both user input (setters) and usage (on() method). coming soon

@ericdrowell
Copy link
Owner

update on this thread: For optimal performance, you may give the new FastLayers a try. When you just want to draw stuff as fast as possible, and you don't care about mouse interactions, node nesting, event pub/sub, etc, FastLayers are a really good choice. You instantiate them like this:

var layer = new FastLayer();

I think this is an even better solution than managing the overhead of checking for situations when creating a hit canvas is required.

Still, there may be cases where you want some shapes to be listened to, and others not, and for some reason you need them all in the same layer. In this case, the hit graph will still need to be generated for the shapes that need it, and Kinetic could auto toggle off listening for shapes that have no handlers bound to them.

@lavrton
Copy link
Contributor

lavrton commented May 16, 2014

I think we should not do this. Main reason is event bubbling. User may listen events on parent, not on shape. So library code will be too complicated if we will add such functionality. It is MUCH easier to manually use shape.listening(false)

@lavrton lavrton closed this as completed May 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants