拖拽bug fix 修复
This commit is contained in:
parent
645fe865f0
commit
3f96dcd730
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -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}
|
|
||||||
/>)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,6 +14,11 @@ class TableHeader extends Component{
|
||||||
constructor(props){
|
constructor(props){
|
||||||
super(props);
|
super(props);
|
||||||
this.currentObj = null;
|
this.currentObj = null;
|
||||||
|
this.state = {
|
||||||
|
border:false
|
||||||
|
}
|
||||||
|
//拖拽宽度处理
|
||||||
|
if(!props.dragborder)return;
|
||||||
this.border = false;
|
this.border = false;
|
||||||
this.drag = {
|
this.drag = {
|
||||||
initPageLeftX:0,
|
initPageLeftX:0,
|
||||||
|
@ -24,9 +29,6 @@ class TableHeader extends Component{
|
||||||
let _da = {};
|
let _da = {};
|
||||||
Object.assign(_da,this.props.rows[0]);
|
Object.assign(_da,this.props.rows[0]);
|
||||||
this.drag.data = JSON.parse(JSON.stringify(this.props.rows[0]));
|
this.drag.data = JSON.parse(JSON.stringify(this.props.rows[0]));
|
||||||
this.state = {
|
|
||||||
border:false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps) {
|
shouldComponentUpdate(nextProps) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import Icon from "bee-icon";
|
import Icon from "bee-icon";
|
||||||
import Checkbox from "bee-checkbox";
|
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import Popover from 'bee-popover';
|
|
||||||
import {sortBy} from './util';
|
import {sortBy} from './util';
|
||||||
/**
|
/**
|
||||||
* 参数: 列拖拽
|
* 参数: 列拖拽
|
||||||
|
|
Loading…
Reference in New Issue