[추억1314] 마우스 오프 방향 체크
12931 단어 마우스
그냥 효과 보고 여기.
<html>
<head> </head>
<body>
<div id="msg"> , 。</div>
<div id="wrap" style="width:200px; height: 100px; line-height:30px; margin: 100px auto; text-align: center; border: 1px solid #99bbe8;">↖↑↗<br/>← →<br/>↙↓↘</div>
<script src="http://common.cnblogs.com/script/jquery.js"></script>
<script>
$("#wrap").on("mouseenter mouseleave",function(e) {
var w = $(this).width();
var h = $(this).height();
var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 45) + 3) % 8;
var dirName = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '];
if(e.type == 'mouseenter'){
$("#msg").html(dirName[direction]+'- ');
}else{
$('#msg').html(dirName[direction]+'- ');
}
});
</script>
</body>
</html>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
js 마우스 이동 방향을 판단하는 방법PC 단말기의 마우스를 옮겨 옮기는 효과가 매우 좋다. 여기서 마우스를 옮겨 옮기는 방법을 판단하고 틈이 나면 효과가 있는 글을 보내지만 물고기를 주는 것보다 물고기를 잡는 것이 낫다. 이 방법이 있는데 효과가 so...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.