jeromeetienne/threex — Issue #11: Clicks register for background objects - domevent.js
Author: Crashthatch
Created: 2012-01-22 23:28:10+00:00
State: open

If you have an object (skybox) with an object (tree) in front of it, clicking on the tree fires the "click" event on both objects. I believe this is normal Javascript behaviour, but without bubbling / "return false" / e.stopPropagation() behaviour it's difficult to stop both events from fireing. I'm not sure if this counts as a bug, or just "partial functionality"?

My actual use case:
A click on an object pops up a menu. A click anywhere else (ie. on skybox) clears the menu. Because both events were firing the menu was popping up and then immidiately being cleared. I avoided it by disabling the "clear" event for 0.1 seconds when the menu was popped up, but it's messy.

Possible fixes:
* Full bubbling behaviour (like JS)
* Check return value when iterating over handlers. If one returns false, stop. (At least in my case, the closer event always fired first).