Perform point conversion along with HitResult.getOptions().

This commit is contained in:
Jürg Lehni 2011-07-08 23:25:27 +02:00
parent cc00f40532
commit 9db96ae898
3 changed files with 8 additions and 3 deletions

View file

@ -36,9 +36,12 @@ HitResult = Base.extend(/** @lends HitResult# */{
*
* @private
*/
getOptions: function(options) {
getOptions: function(point, options) {
// TODO: Consier moving to HitResult / HitEvent?
return options && options._merged ? options : Base.merge({
// Use the converted options object to perform point conversion
// only once.
point: Point.read(arguments, 0, 1),
// Type of item, for instanceof check: PathItem, TexItem, etc
type: Item,
// Tolerance

View file

@ -669,7 +669,8 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
},
hitTest: function(point, options, matrix) {
options = HitResult.getOptions(options);
options = HitResult.getOptions(point, options);
point = options.point;
// Check if the point is withing roughBounds + tolerance, but only if
// this item does not have children, since we'd have to travel up the
// chain already to determine the rough bounds.

View file

@ -182,7 +182,8 @@ var Project = this.Project = Base.extend(/** @lends Project# */{
},
hitTest: function(point, options) {
options = HitResult.getOptions(options);
options = HitResult.getOptions(point, options);
point = options.point;
// 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);