【发布时间】:2013-11-16 19:19:23
【问题描述】:
我试图在拖动开始时调用一个函数,但我不能,这个 div 无法处理调整大小图标区域上的单击或 mousedown 事件,所以我不得不在 mouseover 事件上处理它。
HTML
<div>hey</div>
CSS
div{
width:30%;
border:4px solid green;
resize:horizontal;
overflow:hidden;
}
Javascript
$("div").on("mousemove.resizer",function(e) {
var draggingstarted = false;
var bottom = $(this).offset().top + $(this).outerHeight();
var right = $(this).offset().left + $(this).outerWidth();
if (e.pageY<bottom-3 && e.pageY>bottom-16
&& e.pageX<right-3 && e.pageX>right-16){
if (draggingstarted){
console.log("started dragging");
} else if (e.which==1) draggingstarted=true; //left click
//else if (e.which==0) draggingstarted=false; //no clicks
console.log(e.which, draggingstarted);
}
});
【问题讨论】:
-
@megawac 我可以处理调整大小,但我无法处理调整大小事件的开始。
-
migth help stackoverflow.com/questions/8082729/…
-
当然,如果你想使用调整大小,你可能需要一个插件
-
使用插件将是跨浏览器兼容性的最佳方法
标签: javascript jquery html resize