mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Reverse direction of child-looping in hit-tests, so items that get drawn last are tested first.
This commit is contained in:
parent
48d61b46bf
commit
a580b23f2a
2 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue