Ticket #31505: 31505.patch
| File 31505.patch, 3.7 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/hoverIntent.js
1 1 /*! 2 * hoverIntent r7 // 2013.03.11 // jQuery1.9.1+2 * hoverIntent v1.8.1 // 2014.08.11 // jQuery v1.9.1+ 3 3 * http://cherne.net/brian/resources/jquery.hoverIntent.html 4 4 * 5 5 * You may use hoverIntent under the terms of the MIT license. Basically that 6 6 * means you are free to use hoverIntent as long as this header is left intact. 7 * Copyright 2007, 201 3Brian Cherne7 * Copyright 2007, 2014 Brian Cherne 8 8 */ 9 9 10 10 /* hoverIntent is similar to jQuery's built-in "hover" method except that … … 35 35 // default configuration values 36 36 var cfg = { 37 37 interval: 100, 38 sensitivity: 7,38 sensitivity: 6, 39 39 timeout: 0 40 40 }; 41 41 … … 62 62 var compare = function(ev,ob) { 63 63 ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); 64 64 // compare mouse positions to see if they've crossed the threshold 65 if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {65 if ( Math.sqrt( (pX-cX)*(pX-cX) + (pY-cY)*(pY-cY) ) < cfg.sensitivity ) { 66 66 $(ob).off("mousemove.hoverIntent",track); 67 67 // set hoverIntent state to true (so mouseOut can be called) 68 ob.hoverIntent_s = 1;68 ob.hoverIntent_s = true; 69 69 return cfg.over.apply(ob,[ev]); 70 70 } else { 71 71 // set previous coordinates for next time … … 78 78 // A private function for delaying the mouseOut function 79 79 var delay = function(ev,ob) { 80 80 ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); 81 ob.hoverIntent_s = 0;81 ob.hoverIntent_s = false; 82 82 return cfg.out.apply(ob,[ev]); 83 83 }; 84 84 … … 85 85 // A private function for handling mouse 'hovering' 86 86 var handleHover = function(e) { 87 87 // copy objects to be passed into t (required for event object to be passed in IE) 88 var ev = jQuery.extend({},e);88 var ev = $.extend({},e); 89 89 var ob = this; 90 90 91 91 // cancel hoverIntent timer if it exists 92 92 if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } 93 93 94 // if e.type == "mouseenter"95 if (e.type == "mouseenter") {94 // if e.type === "mouseenter" 95 if (e.type === "mouseenter") { 96 96 // set "previous" X and Y position based on initial entry point 97 97 pX = ev.pageX; pY = ev.pageY; 98 98 // update "current" X and Y position based on mousemove 99 99 $(ob).on("mousemove.hoverIntent",track); 100 100 // start polling interval (self-calling timeout) to compare mouse coordinates over time 101 if ( ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}101 if (!ob.hoverIntent_s) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} 102 102 103 103 // else e.type == "mouseleave" 104 104 } else { … … 105 105 // unbind expensive mousemove event 106 106 $(ob).off("mousemove.hoverIntent",track); 107 107 // if hoverIntent state is true, then call the mouseOut function after the specified delay 108 if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}108 if (ob.hoverIntent_s) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} 109 109 } 110 110 }; 111 111