Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
submodule
Commits
4c3e4db7
Commit
4c3e4db7
authored
Jul 31, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改apolloTable dragFixed
parent
ba4641e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
31 deletions
+25
-31
DragFixed.tsx
components/apolloTable/component/DragFixed.tsx
+7
-14
RightDragFixed.tsx
components/apolloTable/component/RightDragFixed.tsx
+13
-15
Table.less
components/apolloTable/component/Table.less
+2
-1
Table.tsx
components/apolloTable/component/Table.tsx
+3
-1
No files found.
components/apolloTable/component/DragFixed.tsx
View file @
4c3e4db7
...
@@ -3,9 +3,9 @@ import { ResizableBox } from 'react-resizable';
...
@@ -3,9 +3,9 @@ import { ResizableBox } from 'react-resizable';
import
styles
from
'./DragFixed.less'
;
import
styles
from
'./DragFixed.less'
;
const
DragFixed
=
(
props
:
any
)
=>
{
const
DragFixed
=
(
props
:
any
)
=>
{
const
{
initLeft
,
initTop
,
onResizeStart
,
tableWidth
,
showColumns
,
columnWidth
,
columns
,
onResizeStop
}
=
props
;
const
{
tableId
,
initLeft
,
initTop
,
onResizeStart
,
showColumns
,
columnWidth
,
columns
,
onResizeStop
}
=
props
;
// 表格
// 表格
const
container
:
any
=
document
.
querySelector
(
'#tableContainer'
);
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
// 滑块wrap
// 滑块wrap
const
handleWrap
:
any
=
document
.
querySelector
(
'#leftFixedHandleWrap'
);
const
handleWrap
:
any
=
document
.
querySelector
(
'#leftFixedHandleWrap'
);
// 滑块
// 滑块
...
@@ -44,11 +44,11 @@ const DragFixed = (props: any) => {
...
@@ -44,11 +44,11 @@ const DragFixed = (props: any) => {
};
};
const
onResizeHandle
=
(
e
:
any
)
=>
{
const
onResizeHandle
=
(
e
:
any
)
=>
{
const
originLeft
=
container
.
getBoundingClientRect
().
x
||
0
;
const
containerRect
:
any
=
container
.
getBoundingClientRect
()
;
let
inTableLeft
=
e
.
x
-
originLeft
;
let
inTableLeft
=
e
.
x
-
containerRect
.
x
;
// left不能超过表格一半宽度
// left不能超过表格一半宽度
if
(
inTableLeft
>
tableW
idth
/
2
)
{
if
(
inTableLeft
>
containerRect
.
w
idth
/
2
)
{
inTableLeft
=
tableW
idth
/
2
;
inTableLeft
=
containerRect
.
w
idth
/
2
;
}
}
let
fixedWidth
=
0
;
let
fixedWidth
=
0
;
let
index
=
0
;
let
index
=
0
;
...
@@ -60,14 +60,7 @@ const DragFixed = (props: any) => {
...
@@ -60,14 +60,7 @@ const DragFixed = (props: any) => {
break
;
break
;
}
}
}
}
let
leftHandleLeft
=
0
;
const
leftHandleLeft
=
fixedWidth
-
(
showColumns
[
index
].
width
||
columnWidth
);
if
(
inTableLeft
>
fixedWidth
-
(
showColumns
[
index
].
width
||
columnWidth
)
/
2
)
{
// left位于当前列中间偏右
leftHandleLeft
=
fixedWidth
;
}
else
{
// left位于当前列中间偏左
leftHandleLeft
=
fixedWidth
-
(
showColumns
[
index
].
width
||
columnWidth
);
}
// 拖动时显示分割线
// 拖动时显示分割线
dividerWrap
.
style
.
display
=
'block'
;
dividerWrap
.
style
.
display
=
'block'
;
// 分割线取列的边侧位置
// 分割线取列的边侧位置
...
...
components/apolloTable/component/RightDragFixed.tsx
View file @
4c3e4db7
...
@@ -4,18 +4,18 @@ import styles from './DragFixed.less';
...
@@ -4,18 +4,18 @@ import styles from './DragFixed.less';
const
DragFixed
=
(
props
:
any
)
=>
{
const
DragFixed
=
(
props
:
any
)
=>
{
const
{
const
{
tableId
,
initLeft
,
initLeft
,
initTop
,
initTop
,
onResizeStart
,
onResizeStart
,
tableWidth
,
showColumns
,
showColumns
,
columnWidth
,
columnWidth
,
columns
,
columns
,
onResizeStop
,
onResizeStop
,
scrollbarWidth
,
paddingRight
,
}
=
props
;
}
=
props
;
// 表格
// 表格
const
container
:
any
=
document
.
querySelector
(
'#tableContainer'
);
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
// 滑块wrap
// 滑块wrap
const
handleWrap
:
any
=
document
.
querySelector
(
'#rightFixedHandleWrap'
);
const
handleWrap
:
any
=
document
.
querySelector
(
'#rightFixedHandleWrap'
);
// 滑块
// 滑块
...
@@ -57,8 +57,8 @@ const DragFixed = (props: any) => {
...
@@ -57,8 +57,8 @@ const DragFixed = (props: any) => {
const
containerRect
:
any
=
container
.
getBoundingClientRect
();
const
containerRect
:
any
=
container
.
getBoundingClientRect
();
let
inTableRight
=
containerRect
.
right
-
e
.
x
;
let
inTableRight
=
containerRect
.
right
-
e
.
x
;
// left不能超过表格一半宽度
// left不能超过表格一半宽度
if
(
inTableRight
>
tableW
idth
/
2
)
{
if
(
inTableRight
>
containerRect
.
w
idth
/
2
)
{
inTableRight
=
tableW
idth
/
2
;
inTableRight
=
containerRect
.
w
idth
/
2
;
}
}
let
fixedWidth
=
0
;
let
fixedWidth
=
0
;
let
index
=
0
;
let
index
=
0
;
...
@@ -70,20 +70,17 @@ const DragFixed = (props: any) => {
...
@@ -70,20 +70,17 @@ const DragFixed = (props: any) => {
break
;
break
;
}
}
}
}
let
rightHandleLeft
=
fixedWidth
-
(
showColumns
[
index
].
width
||
columnWidth
);
let
rightHandleLeft
=
fixedWidth
-
(
showColumns
[
index
].
width
||
columnWidth
);
// if (inTableRight > fixedWidth - (showColumns[index].width || columnWidth) / 2) {
if
(
fixedWidth
===
inTableRight
)
{
// // left位于当前列中间偏右
rightHandleLeft
=
fixedWidth
;
// rightHandleLeft = fixedWidth;
}
// } else {
// // left位于当前列中间偏左
// rightHandleLeft = fixedWidth - (showColumns[index].width || columnWidth);
// }
// 拖动时显示分割线
// 拖动时显示分割线
dividerWrap
.
style
.
display
=
'block'
;
dividerWrap
.
style
.
display
=
'block'
;
// 分割线取列的边侧位置
// 分割线取列的边侧位置
divider
.
style
.
left
=
`
${
containerRect
.
width
-
scrollbarWidth
-
rightHandleLeft
}
px`
;
divider
.
style
.
left
=
`
${
containerRect
.
width
-
paddingRight
-
rightHandleLeft
}
px`
;
// 拖动线取鼠标位置
// 拖动线取鼠标位置
handleWrap
.
style
.
left
=
`
${
containerRect
.
width
-
scrollbarWidth
-
inTableRight
}
px`
;
handleWrap
.
style
.
left
=
`
${
containerRect
.
width
-
paddingRight
-
inTableRight
}
px`
;
// 滑动过程中滑块始终显示
// 滑动过程中滑块始终显示
// 滑块wrap添加hovered样式
// 滑块wrap添加hovered样式
handleWrap
.
classList
.
add
(
styles
.
hovered
);
handleWrap
.
classList
.
add
(
styles
.
hovered
);
...
@@ -92,6 +89,7 @@ const DragFixed = (props: any) => {
...
@@ -92,6 +89,7 @@ const DragFixed = (props: any) => {
};
};
const
onResizeStopHandle
=
()
=>
{
const
onResizeStopHandle
=
()
=>
{
const
containerRect
:
any
=
container
.
getBoundingClientRect
();
// 当前固定列宽度为分割线的left
// 当前固定列宽度为分割线的left
const
fixedWidth
:
string
=
divider
.
style
.
left
;
const
fixedWidth
:
string
=
divider
.
style
.
left
;
// 样式转数值
// 样式转数值
...
@@ -110,7 +108,7 @@ const DragFixed = (props: any) => {
...
@@ -110,7 +108,7 @@ const DragFixed = (props: any) => {
// 计算获取固定列
// 计算获取固定列
for
(
let
i
=
showColumns
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
showColumns
.
length
-
1
;
i
>=
0
;
i
--
)
{
leftFixedWidth
+=
showColumns
[
i
].
width
||
columnWidth
;
leftFixedWidth
+=
showColumns
[
i
].
width
||
columnWidth
;
if
(
leftFixedWidth
<=
tableWidth
+
scrollbarWidth
-
Number
(
fixedWidthNum
))
{
if
(
leftFixedWidth
<=
containerRect
.
width
-
paddingRight
-
Number
(
fixedWidthNum
))
{
fixedCol
[
showColumns
[
i
].
columnName
]
=
1
;
fixedCol
[
showColumns
[
i
].
columnName
]
=
1
;
}
else
{
}
else
{
break
;
break
;
...
...
components/apolloTable/component/Table.less
View file @
4c3e4db7
...
@@ -117,7 +117,8 @@
...
@@ -117,7 +117,8 @@
background-color: rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.4);
z-index: 4;
z-index: 4;
display: none;
display: none;
pointer-events: none;
//pointer-events: none;
user-select: none;
.widthHandle {
.widthHandle {
position: absolute;
position: absolute;
cursor: ew-resize;
cursor: ew-resize;
...
...
components/apolloTable/component/Table.tsx
View file @
4c3e4db7
...
@@ -639,6 +639,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -639,6 +639,7 @@ export default class AirTable extends Component<TableProps, TableState> {
)
}
)
}
{
canFixed
&&
(
{
canFixed
&&
(
<
LeftDragFixed
<
LeftDragFixed
tableId=
{
tableId
}
initLeft=
{
leftWidth
}
initLeft=
{
leftWidth
}
initTop=
{
headerHeight
}
initTop=
{
headerHeight
}
tableWidth=
{
tableWidth
}
tableWidth=
{
tableWidth
}
...
@@ -741,13 +742,14 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -741,13 +742,14 @@ export default class AirTable extends Component<TableProps, TableState> {
</
div
>
</
div
>
{
canFixed
&&
(
{
canFixed
&&
(
<
RightDragFixed
<
RightDragFixed
tableId=
{
tableId
}
initLeft=
{
tableWidth
-
rightWidth
}
initLeft=
{
tableWidth
-
rightWidth
}
initTop=
{
headerHeight
}
initTop=
{
headerHeight
}
tableWidth=
{
tableWidth
}
tableWidth=
{
tableWidth
}
showColumns=
{
showColumns
}
showColumns=
{
showColumns
}
columnWidth=
{
columnWidth
}
columnWidth=
{
columnWidth
}
columns=
{
columns
}
columns=
{
columns
}
scrollbarWidth=
{
scrollbarWidth
}
paddingRight=
{
paddingRight
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
/>
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment