aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2013-02-27 11:27:44 -0500
committerScott González <scott.gonzalez@gmail.com>2013-02-27 11:27:50 -0500
commit0cf875e5e34e4b2c11802eb856190e6cca649bab (patch)
treed2f4b611c9585f0f44fb6523ea7f32f2261ce249 /demos
parent948563b8b55802c6d4c513065f1b78bbdcff104c (diff)
downloadjquery-ui-0cf875e5e34e4b2c11802eb856190e6cca649bab.tar.gz
jquery-ui-0cf875e5e34e4b2c11802eb856190e6cca649bab.zip
Accordion demo: Clean up hoverintent implementation to avoid using jQuery.event.handle. Thanks Drew Waddell for pointing out the use of an undocumented/deprecated method.
Diffstat (limited to 'demos')
-rw-r--r--demos/accordion/hoverintent.html61
1 files changed, 38 insertions, 23 deletions
diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html
index 023682d4b..0ff63a321 100644
--- a/demos/accordion/hoverintent.html
+++ b/demos/accordion/hoverintent.html
@@ -16,11 +16,11 @@
});
});
- var cfg = ($.hoverintent = {
- sensitivity: 7,
- interval: 100
- });
-
+ /*
+ * hoverIntent | Copyright 2011 Brian Cherne
+ * http://cherne.net/brian/resources/jquery.hoverIntent.html
+ * modified by the jQuery UI team
+ */
$.event.special.hoverintent = {
setup: function() {
$( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler );
@@ -29,41 +29,56 @@
$( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler );
},
handler: function( event ) {
- var that = this,
+ var currentX, currentY, timeout,
args = arguments,
target = $( event.target ),
- cX, cY, pX, pY;
+ previousX = event.pageX,
+ previousY = event.pageY;
function track( event ) {
- cX = event.pageX;
- cY = event.pageY;
+ currentX = event.pageX;
+ currentY = event.pageY;
};
- pX = event.pageX;
- pY = event.pageY;
+
function clear() {
target
.unbind( "mousemove", track )
- .unbind( "mouseout", arguments.callee );
+ .unbind( "mouseout", clear );
clearTimeout( timeout );
}
+
function handler() {
- if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) {
+ var prop,
+ orig = event;
+
+ if ( ( Math.abs( previousX - currentX ) +
+ Math.abs( previousY - currentY ) ) < 7 ) {
clear();
- event.type = "hoverintent";
- // prevent accessing the original event since the new event
+
+ event = $.Event( "hoverintent" );
+ for ( prop in orig ) {
+ if ( !( prop in event ) ) {
+ event[ prop ] = orig[ prop ];
+ }
+ }
+ // Prevent accessing the original event since the new event
// is fired asynchronously and the old event is no longer
// usable (#6028)
- event.originalEvent = {};
- jQuery.event.handle.apply( that, args );
+ delete event.originalEvent;
+
+ target.trigger( event );
} else {
- pX = cX;
- pY = cY;
- timeout = setTimeout( handler, cfg.interval );
+ previousX = currentX;
+ previousY = currentY;
+ timeout = setTimeout( handler, 100 );
}
}
- var timeout = setTimeout( handler, cfg.interval );
- target.mousemove( track ).mouseout( clear );
- return true;
+
+ timeout = setTimeout( handler, 100 );
+ target.bind({
+ mousemove: track,
+ mouseout: clear
+ });
}
};
</script>