; (function () { $.fn.mouseHover = function (li,mouseenter,mouseleave) { return this.each(function () { var $ul = $(this); var $li = $ul.find(li); var headTimer, headerOutTimer, delayTimer, delayTime = 100, dx = 0, dy = 0 $ul.on("mouseenter", li, function (e) { showHover($(this)); if($li.length==0||$li[0]!=$ul.find(li)[0]){ initLi(); } }).on("mouseleave",li, function () { clearTimeout(headTimer); }).on("mouseleave", function () { clearTimeout(headTimer); clearTimeout(headerOutTimer); headerOutTimer = setTimeout(function () { if (typeof mouseleave == "function") { mouseleave() } }, 250) }); function initLi(){ $li.off("mousemove"); $ul.find(li).on("mousemove", function (e) { var _this = $(this); if ((Math.abs(e.pageX - dx) > 6 || Math.abs(e.pageY - dy) > 6) && !_this.hasClass("current") && $ul.find(".zl-pc-nav-column-li.current").length != 0) { dx = e.pageX; dy = e.pageY; showHover(_this); } }); $li = $ul.find(li); } function showHover(_this) { clearTimeout(headTimer); clearTimeout(headerOutTimer); headTimer = setTimeout(function () { $('.lazyload img', _this).trigger("appear"); if (typeof mouseenter == "function") { mouseenter.call(_this) } }, delayTime); } }) } })();