Roo/form/ComboBoxArray.js
[roojs1] / Roo / Resizable.js
index f616070..4502fe6 100644 (file)
@@ -28,6 +28,7 @@ Value   Description
  'sw'    southwest
  'se'    southeast
  'ne'    northeast
+ 'hd'    horizontal drag
  'all'   all
 </pre>
  * <p>Here's an example showing the creation of a typical Resizable:</p>
@@ -418,14 +419,26 @@ Roo.extend(Roo.Resizable, Roo.util.Observable, {
                     y += diffY;
                     h -= diffY;
                     break;
+                case "hdrag":
+                    
+                    if (wi) {
+                        var adiffX = Math.abs(diffX);
+                        var sub = (adiffX % wi); // how much 
+                        if (sub > (wi/2)) { // far enough to snap
+                            diffX = (diffX > 0) ? diffX-sub + wi : diffX+sub - wi;
+                        } else {
+                            // remove difference.. 
+                            diffX = (diffX > 0) ? diffX-sub : diffX+sub;
+                        }
+                    }
+                    x += diffX;
+                    x = Math.max(this.minX, x);
+                    break;
                 case "west":
                     diffX = this.constrain(w, diffX, mw, mxw);
                     x += diffX;
                     w -= diffX;
                     break;
-                case "hdrag":
-                    x += diffX;
-                    break;
                 case "northeast":
                     w += diffX;
                     w = Math.min(Math.max(mw, w), mxw);
@@ -463,7 +476,6 @@ Roo.extend(Roo.Resizable, Roo.util.Observable, {
                     case "southwest":
                         x -= sw - w;
                     break;
-                    case "hdrag":
                     case "west":
                         x -= sw - w;
                         break;
@@ -524,11 +536,14 @@ Roo.extend(Roo.Resizable, Roo.util.Observable, {
                         h = Math.min(Math.max(mh, h), mxh);
                         w = ow * (h/oh);
                         y += th - h;
-                         x += tw - w;
+                        x += tw - w;
                        break;
 
                 }
             }
+            if (pos == 'hdrag') {
+                w = ow;
+            }
             this.proxy.setBounds(x, y, w, h);
             if(this.dynamic){
                 this.resizeElement();
@@ -613,8 +628,12 @@ Roo.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
     this.position = pos;
     this.rz = rz;
     // show north drag fro topdra
-    var handlepos = pos == 'hdrag' ? 'north' : pos;;
+    var handlepos = pos == 'hdrag' ? 'north' : pos;
+    
     this.el = this.tpl.append(rz.el.dom, [handlepos], true);
+    if (pos == 'hdrag') {
+        this.el.setStyle('cursor', 'pointer');
+    }
     this.el.unselectable();
     if(transparent){
         this.el.setOpacity(0);