Skip to content

Commit

Permalink
Worked out a few kinks with the new hit map event triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
rsandor committed Oct 16, 2010
1 parent d006ad3 commit 0196845
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions gury.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ window.$g = window.Gury = (function(window, jQuery) {


// Annotate the object with gury specific members // Annotate the object with gury specific members
if (!isDefined(object._gury)) { if (!isDefined(object._gury)) {
console.log('ADDED ANNOTATIONS');
object._gury = { visible: true, paused: false, z: this.nextZ() }; object._gury = { visible: true, paused: false, z: this.nextZ() };
} }


Expand Down Expand Up @@ -742,7 +743,7 @@ window.$g = window.Gury = (function(window, jQuery) {
Gury.prototype.mouseleave = eventFunction('mouseleave'); Gury.prototype.mouseleave = eventFunction('mouseleave');


// Adapted from: http://www.quirksmode.org/js/findpos.html // Adapted from: http://www.quirksmode.org/js/findpos.html
function getPositon(gury, e) { function getPosition(gury, e) {
var left = 0, top = 0; var left = 0, top = 0;
var object = gury.canvas; var object = gury.canvas;


Expand All @@ -765,25 +766,30 @@ window.$g = window.Gury = (function(window, jQuery) {
var pos = getPosition(gury, e); var pos = getPosition(gury, e);
var found = false; var found = false;


var sorted = new Set(ord); var sorted = new Set(true);
gury._events[name].each(function(ob) { sorted.add(ob); }); gury._events[name].each(function(ob) {
sorted.add(ob.target);
});


// TODO Look into avoiding resorts // TODO Look into avoiding resorts
sorted.sort(function(a, b) { sorted.sort(function(a, b) {
if (a._gury.z < b._gury.z) { if (a._gury.z < b._gury.z) {
return -1; return 1;
} }
else { else {
return 1; return -1;
} }
}).each(function(ob) { }).each(function(ob) {
if (!found && HitMap.hit(gury, ob, pos.x, pos.y)) { if (!found && HitMap.hit(gury, ob, pos.x, pos.y)) {
found = true; found = true;
gury.trigger(name, ob, e); gury.trigger(name, ob, e);
if (closure) {
closure.call(ob);
}
} }
}); });


if (!found) { if (!found && closure) {
closure.call(null); closure.call(null);
} }
} }
Expand Down Expand Up @@ -818,6 +824,7 @@ window.$g = window.Gury = (function(window, jQuery) {
gury.trigger('mouseleave', over, e); gury.trigger('mouseleave', over, e);
} }
gury.trigger('mouseenter', this); gury.trigger('mouseenter', this);
over = this;
} }
}); });
}; };
Expand Down

0 comments on commit 0196845

Please sign in to comment.