jquery鼠标停止移动事件
2018-10-12 14:03
483 查看
<script src="jquery.js"></script>
<script>
(function($){
$.fn.moveStopEvent = function(callback){
return this.each(function() {
var x = 0,
y = 0,
x1 = 0,
y1 = 0,
isRun = false,
si,
self = this;var sif = function(){
si = setInterval(function(){
if(x == x1 && y ==y1){
clearInterval(si);
isRun = false;
callback && callback.call(self);
}
x = x1;
y = y1;
}, 500);
}$(this).mousemove(function(e){
x1 = e.pageX;
y1 = e.pageY;
!isRun && sif(), isRun = true;
}).mouseout(function(){
clearInterval(si);
isRun = false;
});
});
}
})(jQuery);$(function(){
$("#div1,#div2").moveStopEvent(function(){
alert($(this).attr("id"));
}
);
});
</script>
<div id="div1" style="width:200px;height:100px;background-color:#ccc;">div1</div>
<br/>
<div id="div2" style="width:200px;height:100px;background-color:#ccc;">div2</div>
您可能感兴趣的文章:
相关文章推荐
- jquery鼠标停止移动事件
- jquery鼠标停止移动事件
- jQuery操作表格背景色迭代和鼠标移动事件(CSS中使用expression)
- jQuery事件 鼠标移动效果 onmouseover方法与onmouseout方法
- jquery模拟实现鼠标指针停止运动事件
- jQuery移动页面开发中的触摸事件与虚拟鼠标事件简介
- jQuery移动页面开发中的触摸事件与虚拟鼠标事件简介
- jQuery鼠标滚动事件
- MFC 图片控件图片加载以及鼠标移动事件和鼠标点击事件
- 自定义圆形,可根据鼠标移动,按下移动抬起事件
- jQuery事件之鼠标事件
- jQuery鼠标随意移动div
- jQuery实现鼠标滑过图片移动特效
- jQuery – 鼠标经过(hover)事件的延时处理
- (笔记)鼠标移动到一个 元素上所触发的事件
- 移动端 jquery 长按触发移动事件 <升级版>
- CSS鼠标响应事件经过、移动、点击示例介绍
- 提示信息 感应鼠标移动事件 自动显示url页面内容
- jQuery监听鼠标滚轮事件
- 鼠标移动事件