拖拽bug fix 修复

This commit is contained in:
jonyshi 2018-05-13 15:02:53 +08:00
parent 645fe865f0
commit 3f96dcd730
5 changed files with 11 additions and 2585 deletions

2514
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,70 +0,0 @@
import React, { Component } from "react";
import Icon from "bee-icon";
import Checkbox from "bee-checkbox";
import ReactDOM from 'react-dom';
import Popover from 'bee-popover';
import {sortBy} from './util';
class ResizableTh extends Component {
constructor(props) {
super(props);
this.state = {
width:0
}
}
componentWillReceiveProps(nextProps){
if(nextProps.columns != this.props.columns){
}
}
onMouseDown=(event,data)=>{
this.mouse = true;
this.dragBorderObj.startScreenX = event.screenX;
}
onMouseMove=(event,data)=>{
if(!this.mouse)return;
let endx = (event.screenX-this.dragBorderObj.startScreenX);
let {columns:_columns} = this.state;
let columns = [];
Object.assign(columns,_columns);
// let currentIndex = columns.findIndex((_da,i)=>_da.key == data.key);
// currentIndex = currentIndex==0?currentIndex:(currentIndex-1);
let currObj = columns.find((_da,i)=>_da.key == data.key);
if(!currObj)return;
currObj.width = currObj.width?(currObj.width+endx):endx;
this.setState({
columns
});
}
getTarget=(evt)=>{
return evt.target || evt.srcElement;
}
onMouseUp=(event,data)=>{
let endx = (event.screenX-this.dragBorderObj.startScreenX);
this.mouse = false;
}
render() {
const {className} = this.props;
return (<th {...this.props} className={`${className} u-table-drag-border`}
// onDragStart={this.onDragStart} onDragOver={this.onDragOver} onDrop={this.onDrop}
// onDragEnter={this.onDragEnter}
// draggable={draggable}
onMouseDown={this.onMouseDown}
onMouseMove={this.onMouseMove}
onMouseUp={this.onMouseUp}
/>)
}
}

View File

@ -14,6 +14,11 @@ class TableHeader extends Component{
constructor(props){
super(props);
this.currentObj = null;
this.state = {
border:false
}
//拖拽宽度处理
if(!props.dragborder)return;
this.border = false;
this.drag = {
initPageLeftX:0,
@ -24,9 +29,6 @@ class TableHeader extends Component{
let _da = {};
Object.assign(_da,this.props.rows[0]);
this.drag.data = JSON.parse(JSON.stringify(this.props.rows[0]));
this.state = {
border:false
}
}
shouldComponentUpdate(nextProps) {

View File

@ -1,8 +1,6 @@
import React, { Component } from "react";
import Icon from "bee-icon";
import Checkbox from "bee-checkbox";
import ReactDOM from 'react-dom';
import Popover from 'bee-popover';
import {sortBy} from './util';
/**
* 参数: 列拖拽