用到了jquery,函数原型如下:
js 代码
- /*
- * @src handle element
- * @on_mousedown function(handlingElement,x,y)
- * @on_mousemove function(handlingElement,dx,dy,ddx,ddy,x,y);
- * x,y current x,y
- * dx,dy delta x,y from mousedown
- * ddx,ddy delta x,y from last move
- */
- function handleDrag(src,on_mousedown,on_mousemove){
- ...
- }
例子:
js 代码
- $("td").each(function(){
- var ow,oh;//记录第一次的宽度和高度
- handleDrag(this,
- function(src,x,y){
- ow=$(src).width();
- oh=$(src).height();
- },
- function(src,x,y,dx,dy,ddx,ddy){
- p=$(src);
- p.width(ow+dx);
- p.height(oh+dy);
- });
- });