Commit 76435779 authored by zhangwenshuai's avatar zhangwenshuai

update dragResize dir and fixed ui

parent 4d970a83
...@@ -36,6 +36,10 @@ const DragFixed = (props: any) => { ...@@ -36,6 +36,10 @@ const DragFixed = (props: any) => {
const onMouseMoveWrap = (e: any) => { const onMouseMoveWrap = (e: any) => {
// 滑块位置跟随鼠标上下移动 // 滑块位置跟随鼠标上下移动
const handleWrapRect = handleWrap.getBoundingClientRect();
if (e.clientY < handleWrapRect.y) {
return;
}
handle.style.top = `${e.clientY}px`; handle.style.top = `${e.clientY}px`;
}; };
...@@ -51,7 +55,7 @@ const DragFixed = (props: any) => { ...@@ -51,7 +55,7 @@ const DragFixed = (props: any) => {
onResizeStart(); onResizeStart();
} }
const originLeft = container.getBoundingClientRect().x || 0; const originLeft = container.getBoundingClientRect().x || 0;
handleWrap.style.top = 0; // handleWrap.style.top = 0;
handleWrap.style.left = `${e.x - originLeft}px`; handleWrap.style.left = `${e.x - originLeft}px`;
}; };
...@@ -95,7 +99,7 @@ const DragFixed = (props: any) => { ...@@ -95,7 +99,7 @@ const DragFixed = (props: any) => {
dividerWrap.style.display = 'none'; dividerWrap.style.display = 'none';
// 滑块wrap移除hovered样式 // 滑块wrap移除hovered样式
handleWrap.classList.remove(styles.hovered); handleWrap.classList.remove(styles.hovered);
handleWrap.style.top = `${initTop}px`; // handleWrap.style.top = `${initTop}px`;
handleWrap.style.left = fixedWidth; handleWrap.style.left = fixedWidth;
// 滑块隐藏 // 滑块隐藏
handle.style.opacity = 0; handle.style.opacity = 0;
......
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
width: 2px; width: 2px;
height: 100%; height: 100%;
bottom: 0; bottom: 0;
right: -1px; right: 0px;
cursor: ew-resize; cursor: ew-resize;
z-index: 1; z-index: 1;
background: #ececec; background: #ececec;
&.right{
left: 0px;
}
&:hover { &:hover {
background-color: rgb(33, 150, 243); background-color: rgb(33, 150, 243);
} }
......
import React from 'react'; import React from 'react';
import classNames from 'classnames';
import { ResizableBox } from 'react-resizable'; import { ResizableBox } from 'react-resizable';
import { getCache, saveCache } from '../utils/cache'; import { getCache, saveCache } from '../utils/cache';
import styles from './DragResized.less'; import styles from './DragResized.less';
const DragResized = (props: any) => { const DragResized = (props: any) => {
const { style, columnName, tableId, canResized, onDragResized, onDragResizedCb, cachedFeAttr, columns } = props; const {
style,
columnName,
tableId,
canResized,
onDragResized,
onDragResizedCb,
cachedFeAttr,
columns,
position,
} = props;
if (!canResized) { if (!canResized) {
return <div style={style}>{props.children}</div>; return <div style={style}>{props.children}</div>;
} }
...@@ -65,7 +76,7 @@ const DragResized = (props: any) => { ...@@ -65,7 +76,7 @@ const DragResized = (props: any) => {
height={style.height} height={style.height}
handle={ handle={
<span <span
className={styles.handleWidth} className={position === 'right' ? classNames(styles.handleWidth, styles.right) : styles.handleWidth}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
}} }}
...@@ -76,6 +87,7 @@ const DragResized = (props: any) => { ...@@ -76,6 +87,7 @@ const DragResized = (props: any) => {
onResize={onResizeWidth} onResize={onResizeWidth}
onResizeStop={onResizeWidthStop} onResizeStop={onResizeWidthStop}
draggableOpts={{ enableUserSelectHack: false }} draggableOpts={{ enableUserSelectHack: false }}
resizeHandles={position === 'right' ? ['w'] : ['e']}
> >
{props.children} {props.children}
</ResizableBox> </ResizableBox>
......
...@@ -37,6 +37,10 @@ const DragFixed = (props: any) => { ...@@ -37,6 +37,10 @@ const DragFixed = (props: any) => {
const onMouseMoveWrap = (e: any) => { const onMouseMoveWrap = (e: any) => {
// 滑块位置跟随鼠标上下移动 // 滑块位置跟随鼠标上下移动
const handleWrapRect = handleWrap.getBoundingClientRect();
if (e.clientY < handleWrapRect.y) {
return;
}
handle.style.top = `${e.clientY}px`; handle.style.top = `${e.clientY}px`;
}; };
...@@ -52,7 +56,7 @@ const DragFixed = (props: any) => { ...@@ -52,7 +56,7 @@ const DragFixed = (props: any) => {
onResizeStart(); onResizeStart();
} }
const originLeft = container.getBoundingClientRect().x || 0; const originLeft = container.getBoundingClientRect().x || 0;
handleWrap.style.top = 0; // handleWrap.style.top = 0;
handleWrap.style.left = `${e.x - originLeft}px`; handleWrap.style.left = `${e.x - originLeft}px`;
}; };
...@@ -101,7 +105,7 @@ const DragFixed = (props: any) => { ...@@ -101,7 +105,7 @@ const DragFixed = (props: any) => {
dividerWrap.style.display = 'none'; dividerWrap.style.display = 'none';
// 滑块wrap移除hovered样式 // 滑块wrap移除hovered样式
handleWrap.classList.remove(styles.hovered); handleWrap.classList.remove(styles.hovered);
handleWrap.style.top = `${initTop}px`; // handleWrap.style.top = `${initTop}px`;
handleWrap.style.left = fixedWidth; handleWrap.style.left = fixedWidth;
// 滑块隐藏 // 滑块隐藏
handle.style.opacity = 0; handle.style.opacity = 0;
......
...@@ -270,6 +270,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -270,6 +270,7 @@ export default class AirTable extends Component<TableProps, TableState> {
cachedFeAttr={cachedFeAttr} cachedFeAttr={cachedFeAttr}
onDragResizedCb={this.onDragResizedCb} onDragResizedCb={this.onDragResizedCb}
columns={formatColumns} columns={formatColumns}
position={position}
> >
<DragSorted <DragSorted
columnName={columnName} columnName={columnName}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment