diff --git a/.gitignore b/.gitignore
index 8cec646..5e7f478 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,4 +36,5 @@
ehthumbs.db
Thumbs.db
-node_modules
\ No newline at end of file
+node_modules
+*.bak
\ No newline at end of file
diff --git a/angular-resizable.min.js b/angular-resizable.min.js
index c7ed294..6774cb5 100644
--- a/angular-resizable.min.js
+++ b/angular-resizable.min.js
@@ -1 +1 @@
-angular.module("angularResizable",[]).directive("resizable",function(){function e(e){void 0===t?(t=e,setTimeout(function(){t(),t=void 0},100)):t=e}var t;return{restrict:"AE",scope:{rDirections:"=",rCenteredX:"=",rCenteredY:"=",rWidth:"=",rHeight:"=",rFlex:"=",rGrabber:"@",rDisabled:"@"},link:function(t,r,i){t.$watch("rWidth",function(e){r[0].style.width=t.rWidth+"px"}),t.$watch("rHeight",function(e){r[0].style.height=t.rHeight+"px"}),r.addClass("resizable");for(var n,s,a,l,o,d=window.getComputedStyle(r[0],null),u=t.rDirections,c=t.rCenteredX?2:1,h=t.rCenteredY?2:1,p=t.rGrabber?t.rGrabber:"",x={},g=function(e){x.width=!1,x.height=!1,"x"==o?x.width=parseInt(t.rFlex?r[0].style.flexBasis:r[0].style.width):x.height=parseInt(t.rFlex?r[0].style.flexBasis:r[0].style.height),x.id=r[0].id,x.evt=e},f=function(i){var d="x"==o?a-i.clientX:a-i.clientY;switch(l){case"top":t.rFlex?r[0].style.flexBasis=s+d*h+"px":r[0].style.height=s+d*h+"px";break;case"right":t.rFlex?r[0].style.flexBasis=n-d*c+"px":r[0].style.width=n-d*c+"px";break;case"bottom":t.rFlex?r[0].style.flexBasis=s-d*h+"px":r[0].style.height=s-d*h+"px";break;case"left":t.rFlex?r[0].style.flexBasis=n+d*c+"px":r[0].style.width=n+d*c+"px"}g(i),e(function(){t.$emit("angular-resizable.resizing",x)})},b=function(e){g(e),t.$emit("angular-resizable.resizeEnd",x),t.$apply(),document.removeEventListener("mouseup",b,!1),document.removeEventListener("mousemove",f,!1),r.removeClass("no-transition")},m=function(e,i){l=i,o="left"==l||"right"==l?"x":"y",a="x"==o?e.clientX:e.clientY,n=parseInt(d.getPropertyValue("width")),s=parseInt(d.getPropertyValue("height")),r.addClass("no-transition"),document.addEventListener("mouseup",b,!1),document.addEventListener("mousemove",f,!1),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1,g(e),t.$emit("angular-resizable.resizeStart",x),t.$apply()},v=0;v",p={},x=function(e){p.width=!1,p.height=!1,"x"==u?p.width=parseInt(t.rFlex?i[0].style.flexBasis:i[0].style.width):p.height=parseInt(t.rFlex?i[0].style.flexBasis:i[0].style.height),p.id=i[0].id,p.evt=e,p.originalWidth=n,p.originalHeight=a},m=function(r){var c,g="x"==u?o-r.clientX:o-r.clientY,m=t.rGrid[0]||1,b=t.rGrid[1]||1,v=t.rLimitResizeTo;switch(g="x"==u?Math.round(g/m)*m:Math.round(g/b)*b,d){case"top":if(c=l+g*f,angular.isDefined(v)&&c>a+b*v)return;t.rFlex?i[0].style.flexBasis=l+g*f+"px":i[0].style.height=l+g*f+"px";break;case"right":if(c=s-g*h,angular.isDefined(v)&&c>n+m*v)return;t.rFlex?i[0].style.flexBasis=c+"px":i[0].style.width=c+"px";break;case"bottom":if(c=l-g*f,angular.isDefined(v)&&a-b*v>c)return;t.rFlex?i[0].style.flexBasis=l-g*f+"px":i[0].style.height=l-g*f+"px";break;case"left":if(c=s+g*h,angular.isDefined(v)&&n-m*v>c)return;t.rFlex?i[0].style.flexBasis=s+g*h+"px":i[0].style.width=s+g*h+"px"}x(r),e(function(){t.$emit("angular-resizable.resizing",p)})},b=function(e){x(e),t.$emit("angular-resizable.resizeEnd",p),t.$apply(),document.removeEventListener("mouseup",b,!1),document.removeEventListener("mousemove",m,!1),i.removeClass("no-transition")},v=function(e,r){d=r,u="left"==d||"right"==d?"x":"y",o="x"==u?e.clientX:e.clientY;var c=i[0].getBoundingClientRect();s=parseInt(c.width),l=parseInt(c.height),n=s,a=l,i.addClass("no-transition"),document.addEventListener("mouseup",b,!1),document.addEventListener("mousemove",m,!1),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1,x(e),t.$emit("angular-resizable.resizeStart",p),t.$apply()},y=0;y originalH+(gridY*limitResizeTo) ) return;
if(scope.rFlex) { element[0].style.flexBasis = h + (offset * vy) + 'px'; }
else { element[0].style.height = h + (offset * vy) + 'px'; }
break;
case 'right':
- if(scope.rFlex) { element[0].style.flexBasis = w - (offset * vx) + 'px'; }
- else { element[0].style.width = w - (offset * vx) + 'px'; }
+ futureDimension = w - (offset * vx);
+ if ( angular.isDefined(limitResizeTo) && futureDimension > originalW+(gridX*limitResizeTo) ) return;
+ if(scope.rFlex) { element[0].style.flexBasis = futureDimension + 'px'; }
+ else { element[0].style.width = futureDimension + 'px'; }
break;
case 'bottom':
+ futureDimension = h - (offset * vy);
+ if ( angular.isDefined(limitResizeTo) && futureDimension < originalH-(gridY*limitResizeTo) ) return;
if(scope.rFlex) { element[0].style.flexBasis = h - (offset * vy) + 'px'; }
else { element[0].style.height = h - (offset * vy) + 'px'; }
break;
case 'left':
+ futureDimension = w + (offset * vx);
+ if ( angular.isDefined(limitResizeTo) && futureDimension < originalW-(gridX*limitResizeTo) ) return;
if(scope.rFlex) { element[0].style.flexBasis = w + (offset * vx) + 'px'; }
else { element[0].style.width = w + (offset * vx) + 'px'; }
break;
}
+
updateInfo(e);
throttle(function() { scope.$emit("angular-resizable.resizing", info);});
};
@@ -93,8 +117,15 @@ angular.module('angularResizable', [])
dragDir = direction;
axis = dragDir == 'left' || dragDir == 'right' ? 'x' : 'y';
start = axis == 'x' ? e.clientX : e.clientY;
- w = parseInt(style.getPropertyValue("width"));
- h = parseInt(style.getPropertyValue("height"));
+
+ // IE returns different values using "style.getPropertyValue"
+ //w = parseInt(style.getPropertyValue("width"));
+ //h = parseInt(style.getPropertyValue("height"));
+ var elRect = element[0].getBoundingClientRect();
+ w = parseInt(elRect.width);
+ h = parseInt(elRect.height);
+ originalW = w;
+ originalH = h;
//prevent transition while dragging
element.addClass('no-transition');