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

Autostart: false not working #63

Open
bitflower opened this issue Aug 24, 2014 · 1 comment
Open

Autostart: false not working #63

bitflower opened this issue Aug 24, 2014 · 1 comment

Comments

@bitflower
Copy link

When set to false the canvas will start to draw with the mouse anyway. I have tried mousemove and touchmove events. Same behaviour across browsers. Any idea? Thanks!

Here's the jsFiddle:

http://jsfiddle.net/bitflower/ss3dkhnz/3/

@soulwire
Copy link
Owner

Hi! Thanks for trying sketch and for finding creating this issue. The problem is that mouse events are bound and triggered even if the sketch isn't running (i.e the update/draw loop is stopped) which is the state it's in when you tell sketch not to autostart.

On the one hand, it would make sense to prevent these events from firing if the sketch isn't running. However, you may still want to receive things like resize events even if it isn't and in some cases even mouse events (perhaps you're tracking the mouse but not drawing.) Regardless, the current architecture means that all events are handled in the same way and so I'd need to add special cases for this.

The intended meaning for the running flag (which is what's toggled when you start or stop a sketch) was to reflect state of the update/draw loop which happens each frame. I think this is an interesting case though and worth thinking about.

In the meantime and as a quick fix you can just check the running flag in your mouse handlers (example) or for your specific use case, use the dragging flag (example).

I hope that solves your problem for now and if you and others think that stopping (or not starting) the sketch should mean that all events are disabled then I can make this change to the library.

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

No branches or pull requests

2 participants