Explorar el Código

休整代码格式

方正 hace 7 años
padre
commit
3df386e56e
Se han modificado 2 ficheros con 21 adiciones y 10 borrados
  1. 16 8
      src/lib/dragact.tsx
  2. 5 2
      src/lib/gridItem.tsx

+ 16 - 8
src/lib/dragact.tsx

@@ -189,11 +189,11 @@ export class Dragact extends React.Component<DragactProps, DragactState> {
 
     onDrag(layoutItem: GridItemEvent) {
 
-        const { GridY, UniqueKey } = layoutItem
-        const moving = GridY - this.state.GridYMoving
+        const { GridY, UniqueKey } = layoutItem;
+        const moving = GridY - this.state.GridYMoving;
 
-        const newLayout = layoutCheck(this.state.layout, layoutItem, UniqueKey, UniqueKey/*用户移动方块的key */, moving)
-        const { compacted, mapLayout } = compactLayout(newLayout, layoutItem)
+        const newLayout = layoutCheck(this.state.layout, layoutItem, UniqueKey, UniqueKey/*用户移动方块的key */, moving);
+        const { compacted, mapLayout } = compactLayout(newLayout, layoutItem);
 
         this.setState({
             GridXMoving: layoutItem.GridX,
@@ -235,7 +235,7 @@ export class Dragact extends React.Component<DragactProps, DragactState> {
                 GridY={GridYMoving}
                 w={wMoving}
                 h={hMoving}
-                style={{ background: 'rgba(15,15,15,0.3)', zIndex: dragType === 'drag' ? 1 : 10, transition: ' all .15s' }}
+                style={{ background: 'rgba(15,15,15,0.3)', zIndex: dragType === 'drag' ? 1 : 10, transition: ' all .15s ease-out' }}
                 isUserMove={!placeholderMoving}
                 dragType={dragType}
                 canDrag={false}
@@ -303,7 +303,7 @@ export class Dragact extends React.Component<DragactProps, DragactState> {
     }
 
     getGridItem(child: any, index: number) {
-        const { dragType, mapLayout } = this.state
+        const { dragType, mapLayout } = this.state;
         var { col, width, padding, rowHeight, margin } = this.props;
         if (mapLayout) {
             const renderItem = layoutItemForkey(mapLayout, child.key);
@@ -339,13 +339,21 @@ export class Dragact extends React.Component<DragactProps, DragactState> {
         }
     }
     render() {
-        const { width, className } = this.props;
+        const {
+            width,
+            className
+        } = this.props;
         const { containerHeight } = this.state;
 
         return (
             <div
                 className={stringJoin('DraggerLayout', className + '')}
-                style={{ left: 100, width: width, height: containerHeight, zIndex: 1 }}
+                style={{
+                    left: 100,
+                    width: width,
+                    height: containerHeight,
+                    zIndex: 1
+                }}
             >
                 {React.Children.map(this.props.children,
                     (child, index) => this.getGridItem(child, index)

+ 5 - 2
src/lib/gridItem.tsx

@@ -209,8 +209,11 @@ export default class GridItem extends React.Component<GridItemProps, {}> {
 
             <Dragger
                 style={{
-                    ...style, width: wPx, height: hPx, position: 'absolute',
-                    transition: this.props.isUserMove ? '' : 'all .2s',
+                    ...style,
+                    width: wPx,
+                    height: hPx,
+                    position: 'absolute',
+                    transition: this.props.isUserMove ? '' : 'all .2s ease-out',
                     zIndex: this.props.isUserMove ? (this.props.dragType === 'drag' ? 10 : 2) : 2
                 }}
                 onDragStart={this.onDragStart}