浏览代码

[build]0.2.8

方正 7 年之前
父节点
当前提交
072648347b
共有 5 个文件被更改,包括 32 次插入18 次删除
  1. 0 0
      build/react-dragger-layout.js
  2. 14 8
      dist/example/AddRemove/index.js
  3. 16 8
      dist/src/lib/GridItem.js
  4. 1 1
      dist/src/lib/dragact.js
  5. 1 1
      package.json

文件差异内容过多而无法显示
+ 0 - 0
build/react-dragger-layout.js


+ 14 - 8
dist/example/AddRemove/index.js

@@ -27,10 +27,14 @@ var Words = [
 ];
 var Card = function (_a) {
     var item = _a.item, provided = _a.provided, onDelete = _a.onDelete;
-    return (React.createElement("div", __assign({ className: 'layout-Item' }, provided.props, provided.dragHandle),
+    return (React.createElement("div", __assign({ className: "layout-Item" }, provided.props, provided.dragHandle),
         React.createElement("div", { style: {
                 position: 'absolute',
-                width: 10, height: 10, right: 15, top: 5, cursor: 'pointer'
+                width: 10,
+                height: 10,
+                right: 15,
+                top: 5,
+                cursor: 'pointer'
             }, onClick: function () { return onDelete(item.key); } }, "\u274C"),
         React.createElement("div", { style: { padding: 5, textAlign: 'center', color: '#595959' } }, item.content)));
 };
@@ -39,7 +43,7 @@ var fakeData = function () {
     return Words.map(function (item, index) {
         if (index % 4 === 0)
             Y++;
-        return __assign({}, item, { GridX: index % 4 * 4, GridY: Y * 4, w: 4, h: 3, key: index });
+        return __assign({}, item, { GridX: (index % 4) * 4, GridY: Y * 4, w: 4, h: 3, key: index });
     });
 };
 var makeOne = function () {
@@ -53,10 +57,12 @@ var AddRemove = /** @class */ (function (_super) {
             layout: fakeData()
         };
         _this.handleClick = function () {
+            var change = _this.state.layout.map(function (item) {
+                return __assign({}, item, { content: '21312' });
+            });
             _this.setState({
-                layout: _this.state.layout.concat([makeOne()])
+                layout: change.concat([makeOne()])
             });
-            console.log(_this.state.layout);
         };
         _this.hanldeOnDelete = function (key) {
             var layout = _this.state.layout.filter(function (item) {
@@ -70,8 +76,7 @@ var AddRemove = /** @class */ (function (_super) {
         };
         return _this;
     }
-    AddRemove.prototype.componentDidMount = function () {
-    };
+    AddRemove.prototype.componentDidMount = function () { };
     AddRemove.prototype.render = function () {
         var _this = this;
         var margin = [5, 5];
@@ -88,9 +93,10 @@ var AddRemove = /** @class */ (function (_super) {
             React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
                 React.createElement("div", null,
                     React.createElement("h1", { style: { textAlign: 'center' } }, "AddRemove Demo"),
+                    React.createElement("h3", { style: { textAlign: 'center' } }, "\u5728\u8FD9\u4E2A\u5E03\u5C40\u4E2D\uFF0C\u65B0\u589E\u4E00\u4E2A\u5E03\u5C40\uFF0C\u4F1A\u65B0\u52A0\u5165\u4E00\u4E2A\u5E03\u5C40"),
                     React.createElement("button", { onClick: this.handleClick }, "\u65B0\u589E"),
                     React.createElement(Dragact, __assign({}, dragactInit), function (item, provided) {
-                        return React.createElement(Card, { item: item, provided: provided, onDelete: _this.hanldeOnDelete });
+                        return (React.createElement(Card, { item: item, provided: provided, onDelete: _this.hanldeOnDelete }));
                     })))));
     };
     return AddRemove;

+ 16 - 8
dist/src/lib/GridItem.js

@@ -87,14 +87,22 @@ var GridItem = /** @class */ (function (_super) {
         };
     };
     GridItem.prototype.shouldComponentUpdate = function (props, state) {
-        return this.props.GridX !== props.GridX ||
-            this.props.GridY !== props.GridY ||
-            this.props.isUserMove !== props.isUserMove ||
-            this.props.w !== props.w ||
-            this.props.h !== props.h ||
-            this.props.containerWidth !== props.containerWidth ||
-            this.props.col !== props.col ||
-            this.props.rowHeight !== this.props.rowHeight;
+        var _this = this;
+        var isUpdate = false;
+        Object.keys(props).forEach(function (key) {
+            if (props[key] !== _this.props[key]) {
+                isUpdate = true;
+            }
+        });
+        return isUpdate;
+        // return this.props.GridX !== props.GridX ||
+        //     this.props.GridY !== props.GridY ||
+        //     this.props.isUserMove !== props.isUserMove ||
+        //     this.props.w !== props.w ||
+        //     this.props.h !== props.h ||
+        //     this.props.containerWidth !== props.containerWidth ||
+        //     this.props.col !== props.col ||
+        //     this.props.rowHeight !== props.rowHeight
     };
     /**宽和高计算成为px */
     GridItem.prototype.calWHtoPx = function (w, h) {

+ 1 - 1
dist/src/lib/dragact.js

@@ -185,7 +185,7 @@ var Dragact = /** @class */ (function (_super) {
             var copyed_2 = __assign({}, this.state.mapLayout);
             var newLayout = nextProps.layout.map(function (v) {
                 if (copyed_2[v.key]) {
-                    return __assign({}, v, copyed_2[v.key]);
+                    return __assign({}, v, { GridX: copyed_2[v.key].GridX, GridY: copyed_2[v.key].GridY, w: copyed_2[v.key].w, h: copyed_2[v.key].h, key: copyed_2[v.key].key });
                 }
                 return __assign({}, v, { isUserMove: false, key: v.key + '' });
             });

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dragact",
-  "version": "0.2.7",
+  "version": "0.2.8",
   "description": "A powerful draggable layout system",
   "main": "index.js",
   "scripts": {

部分文件因为文件数量过多而无法显示