Fixbug: it cannot be returned after overflow. It is added to the range and moved. For more information, see.
The Code is as follows:
/*
* JqDnR-Minimalistic Drag 'n' Resize for jQuery.
*
* Copyright (c) 2007 Brice Burgess , Http://www.iceburg.net/
* Licensed under the MIT License:
* Http://www.opensource.org/licenses/mit-license.php
*
* $ Version: 2007.08.19 + r2
* Last modified by leegle 2011.02.11
* Fix bug: it cannot be returned after overflow. It is added to move within the range.
*/
(Function ($ ){
$. Fn. jqDrag = function (h) {return I (this, h, 'D ');};
$. Fn. jqResize = function (h) {return I (this, h, 'R ');};
$. JqDnR = {dnr :{}, e: 0,
Drag: function (v ){
If (M. k = 'D '){
// Modified location: 14:35:19, January 1, February 11, Year 11
E.css ({left: (M. X + v. pageX-M. pX) <0? 0 :( M. X + v. pageX-M. pX) }
Else syntax e.css ({width: Math. max (v. pageX-M. pX + M.W, 0), height: Math. max (v. pageY-M. pY + M. h, 0)}); return false ;}
},
Stop: function () {E.css ('opacity ', M. o); $ (document ). unbind ('mousemove ', J. drag ). unbind ('mouseup', J. stop );}
};
Var J = $. jqDnR, M = J. dnr, E = J. e,
I = function (e, h, k ){
Return e. each (function (){
H = (h )? $ (H, e): e;
H. bind ('mousedown', {e: e, k: k}, function (v ){
Var d = v. data, p = {}; E = d. e;
// Attempt utilization of dimensions plugin to fix IE issues
If (E.css ('position ')! = 'Relative '){
P = E. position ();
If (! ($. Browser. msie & ($. browser. version = "6.0") & (E.css ('position') = 'fixed ')){
P. top-= $ (window). scrollTop (); p. left-= $ (window). scrollLeft ()
}
}
M = {X: p. left | f ('left') | 0, Y: p. top | f ('top') | 0, W: f ('width') | E [0]. scrollWidth | 0, H: f ('height') | E [0]. scrollHeight | 0, pX: v. pageX, pY: v. pageY, k: d. k, o: E.css ('opacity ')};
E.css ({opacity: 0.8}); $ (document). mousemove ($. jqDnR. drag). mouseup ($. jqDnR. stop );
Return false;
});
});
},
F = function (k) {return parseInt(E.css (k) | false ;};
}) (JQuery );