Reverse direction of child-looping in hit-tests, so items that get drawn last are tested first.

This commit is contained in:
Jürg Lehni 2011-07-08 21:15:16 +02:00
parent 48d61b46bf
commit a580b23f2a
2 changed files with 4 additions and 2 deletions

View file

@ -687,7 +687,8 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
_hitTest: function(point, options, matrix) {
if (this._children) {
for (var i = 0, l = this._children.length; i < l; i++) {
// Loop backwards, so items that get drawn last are tested first
for (var i = this._children.length - 1; i >= 0; i--) {
var res = this._children[i].hitTest(point, options, matrix);
if (res)
return res;

View file

@ -183,7 +183,8 @@ var Project = this.Project = Base.extend(/** @lends Project# */{
hitTest: function(point, options) {
options = HitResult.getOptions(options);
for (var i = 0, l = this.layers.length; i < l; i++) {
// Loop backwards, so layers that get drawn last are tested first
for (var i = this.layers.length - 1; i >= 0; i--) {
var res = this.layers[i].hitTest(point, options);
if (res)
return res;