$(this).bind("mouseenter mouseleave",function(e){   
  var w = $(this).width();   
  var h = $(this).height();   
  var x = (e.pageX - $(this).offset().left - (w / 2)) * (w > h ? (h / w) : 1);   
  var y = (e.pageY - $(this).offset().top - (h / 2)) * (h > w ? (w / h) : 1);   
  var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;   
  //direction 0'上方',1'右侧',2'下方',3'左侧');
  if(e.type == 'mouseenter'){
  //移入
  }else{
  //移出
  }
})

  

posted on 2017-07-25 22:51  前端小透明  阅读(147)  评论(0编辑  收藏  举报