마우스가 요소에서 1 초 동안 마우스를 가져간 후에 만 mouseover 이벤트를 트리거하는 방법이 있습니까?jQuery mouseover with timing
$("img").mouseover(function() {
$(this).animate({opacity:1}, 200);
});
마우스가 요소에서 1 초 동안 마우스를 가져간 후에 만 mouseover 이벤트를 트리거하는 방법이 있습니까?jQuery mouseover with timing
$("img").mouseover(function() {
$(this).animate({opacity:1}, 200);
});
당신은 여기에있는 hoverIntent() jQuery 플러그인 사용할 수 있습니다 또한 http://cherne.net/brian/resources/jquery.hoverIntent.html
을, 그들은 모바일 브라우저에서 작동하지 않는 사물의 이러한 종류를 사용하거나 아무것도 터치를 사용할 때 당신이 조심해야 할 화면.
예, 터치 스크린 앱에 마우 버 포인터 또는 호버링 이벤트로 감지 될 수있는 마우스 포인터가 내장되어 있지 않은 경우 –
setTimeOut 함수를 사용해야합니다.
setTimeOut(function(){$("img").mouseover(function() {
$(this).animate({opacity:1}, 200);
});
},1000);
밀리 초 단위로 시간이 걸립니다.
1 초 후에 이벤트를 처리하는 타이머 기능 ([1] 참조)을 만들 수 있습니다. 그 함수를 배열에 저장하거나 "window"에 직접 저장할 수 있습니다. 타이머 함수가 트리거되기 전에 "mouseout"이 발생하면 취소 할 수 있습니다.
$("img").on("mouseover mouseout", function() {
var tid = 0;
return function(e) {
var elem = $(this);
clearTimeout(tid);
if (e.type == "mouseover") {
tid = setTimeout(function() {
elem.stop(true).animate({
opacity: 1
}, 200);
}, 1000);
}
else {
console.log(elem);
elem.stop(true).animate({
opacity: 0.3
}, 200);
}
};
}());
당신은 http://cherne.net/brian/resources/jquery.hoverIntent.html보고 할 수 있습니다 – j08691
다음 링크를 확인하십시오. [마우스 오버시 까다로운 지연] (http://stackoverflow.com/questions/1510594/tricky-delay-on-mouseover) –