Removed the debug prints, and got back to the original r5 of hoverintent, except for my change to handle mouseenter and mouseleave
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@821 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -38,8 +38,6 @@
|
||||
// override configuration options with user supplied object
|
||||
cfg = $.extend(cfg, g ? { over: f, out: g } : f );
|
||||
|
||||
$('#debug').append('Setup hoverIntent<BR>');
|
||||
|
||||
// instantiate variables
|
||||
// cX, cY = current X and Y position of mouse, updated by mousemove event
|
||||
// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
|
||||
@@ -53,15 +51,12 @@
|
||||
|
||||
// A private function for comparing current and previous mouse position
|
||||
var compare = function(ev,ob) {
|
||||
$('#debug').append('handle timeout<BR>');
|
||||
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
||||
// compare mouse positions to see if they've crossed the threshold
|
||||
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
|
||||
$(ob).unbind("mousemove",track);
|
||||
// set hoverIntent state to true (so mouseOut can be called)
|
||||
ob.hoverIntent_s = 1;
|
||||
$('#debug').append('fire over<BR>');
|
||||
//$('#debug').append(dump(ev));
|
||||
return cfg.over.apply(ob,[ev]);
|
||||
} else {
|
||||
// set previous coordinates for next time
|
||||
@@ -75,29 +70,30 @@
|
||||
var delay = function(ev,ob) {
|
||||
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
||||
ob.hoverIntent_s = 0;
|
||||
$('#debug').append('fire out<BR>');
|
||||
return cfg.out.apply(ob,[ev]);
|
||||
};
|
||||
|
||||
// A private function for handling mouse 'hovering'
|
||||
var handleHover = function(e) {
|
||||
$('#debug').append('handleHover<BR>');
|
||||
// REVISIT <AP>: 20090829; Unknown why mouseenter/mouseleave are being used
|
||||
var etype = e.type;
|
||||
etype = etype.replace(/mouseenter/, "mouseover");
|
||||
etype = etype.replace(/mouseleave/, "mouseout");
|
||||
|
||||
// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
|
||||
var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
|
||||
var p = (etype == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
|
||||
while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
|
||||
if ( p == this ) { return false; }
|
||||
|
||||
// copy objects to be passed into t (required for event object to be passed in IE)
|
||||
var ev = e; //jQuery.extend({},e);
|
||||
var ev = jQuery.extend({},e);
|
||||
var ob = this;
|
||||
|
||||
// cancel hoverIntent timer if it exists
|
||||
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
|
||||
|
||||
// else e.type == "onmouseover"
|
||||
$('#debug').append(e.type + ': _s = ' + ob.hoverIntent_s + '<BR>');
|
||||
if (e.type == "mouseover" || e.type == "mouseenter") {
|
||||
if (etype == "mouseover") {
|
||||
// set "previous" X and Y position based on initial entry point
|
||||
pX = ev.pageX; pY = ev.pageY;
|
||||
// update "current" X and Y position based on mousemove
|
||||
@@ -122,26 +118,19 @@
|
||||
|
||||
$.event.special.hoverintent = {
|
||||
setup: function() {
|
||||
$('#debug').append('setup event hoverintent<BR>');
|
||||
$(this).hoverIntent({
|
||||
over: jQuery.event.special.hoverintent.over,
|
||||
out: jQuery.event.special.hoverintent.out
|
||||
});
|
||||
},
|
||||
teardown: function() {
|
||||
$('#debug').append('tear down hoverintent<BR>');
|
||||
},
|
||||
|
||||
over: function(ev) {
|
||||
$('#debug').append('handle over<BR>');
|
||||
ev.type = 'hoverintent';
|
||||
if (ev.type != 'hoverintent')
|
||||
$('#debug').append('EV TYPE DID NOT TAKE<BR>');
|
||||
//$('#debug').append(dump(ev));
|
||||
jQuery.event.handle.apply(this, arguments);
|
||||
},
|
||||
|
||||
out: function(event) {
|
||||
$('#debug').append('handle out<BR>');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user