方正 преди 7 години
родител
ревизия
4bbee405e7
променени са 3 файла, в които са добавени 10 реда и са изтрити 12 реда
  1. 0 0
      build/react-dragger-layout.js
  2. 1 1
      package.json
  3. 9 11
      src/lib/gridItem.tsx

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
build/react-dragger-layout.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dragact",
-  "version": "0.1.3",
+  "version": "0.1.4",
   "description": "",
   "main": "index.js",
   "scripts": {

+ 9 - 11
src/lib/gridItem.tsx

@@ -50,16 +50,14 @@ export interface GridItemEvent {
 }
 
 
-const checkWidthHeight = (w: number, h: number, col: number) => {
+const checkWidthHeight = (GridX: number, w: number, h: number, col: number) => {
     var newW = w;
     var newH = h;
-    if (w > col) {
-        newW = col;
-    }
-    if(w<1)newW=1;
-    if(h<1)newH=1;
+    if (GridX + w > col - 1) newW = col - GridX //右边界
+    if (w < 1) newW = 1;
+    if (h < 1) newH = 1;
     return {
-        w:newW,h:newH
+        w: newW, h: newH
     }
 
 }
@@ -148,11 +146,11 @@ export default class GridItem extends React.Component<GridItemProps, {}> {
     calPxToWH(wPx: number, hPx: number) {
         const calWidth = this.calColWidth();
 
-        const w = Math.round((wPx-calWidth*0.5) / calWidth)
-        const h = Math.round((hPx-this.props.rowHeight*0.8) / this.props.rowHeight)
+        const w = Math.round((wPx - calWidth * 0.5) / calWidth)
+        const h = Math.round((hPx - this.props.rowHeight * 0.8) / this.props.rowHeight)
         console.log(h);
 
-        return checkWidthHeight(w,h,this.props.col)
+        return checkWidthHeight(this.props.GridX, w, h, this.props.col)
     }
 
     onDragStart(x: number, y: number) {
@@ -180,7 +178,7 @@ export default class GridItem extends React.Component<GridItemProps, {}> {
     }
 
     onResizeStart = (event: any, wPx: number, hPx: number) => {
-        const { GridX, GridY, UniqueKey,w,h } = this.props;
+        const { GridX, GridY, UniqueKey, w, h } = this.props;
         this.props.onResizeStart && this.props.onResizeStart({ GridX, GridY, w, h, UniqueKey: UniqueKey + '', event })
     }
 

Някои файлове не бяха показани, защото твърде много файлове са промени