摘要: 最终效果.gif 这里的关键主要是判断鼠标是从哪个方向进入和离开的 $("li").on("mouseenter mouseleave",function(e) { var w = this.offsetWidth; var h = this.offsetHeight; var toTop = this.getBounding ...
最终效果.gif
这里的关键主要是判断鼠标是从哪个方向进入和离开的
$("li").on("mouseenter mouseleave",function(e) { var w = this.offsetWidth; var h = this.offsetHeight; var toTop = this.getBoundingClientRect().top document.body.scrollTop; //兼容滚动条var x = (e.pageX - this.getBoundingClientRect().left - (w / 2)) * (w