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
9988d5e9
Commit
9988d5e9
authored
Jun 24, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改列伸缩为dom操作
parent
be4f22ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
31 deletions
+26
-31
Table.tsx
components/apolloTable/component/Table.tsx
+26
-29
interface.tsx
components/apolloTable/component/interface.tsx
+0
-2
No files found.
components/apolloTable/component/Table.tsx
View file @
9988d5e9
...
...
@@ -30,6 +30,8 @@ export default class AirTable extends Component<TableProps, TableState> {
grid6
:
any
;
tableContainer
:
any
;
widthHandleWrapper
:
any
;
widthHandle
:
any
;
memoizeData
:
Function
;
...
...
@@ -68,8 +70,6 @@ export default class AirTable extends Component<TableProps, TableState> {
tableWidth
:
width
,
tableHeight
:
height
,
selectedCell
:
null
,
showWidthHandle
:
false
,
widthHandleLeft
:
0
,
};
this
.
config
=
{
overscanColumnCount
:
5
,
...
...
@@ -220,31 +220,19 @@ export default class AirTable extends Component<TableProps, TableState> {
};
// 列伸缩回调
onResizeWidth
=
(
columnName
:
string
,
e
,
{
size
})
=>
{
let
originLeft
=
this
.
tableContainer
&&
this
.
tableContainer
.
offsetParent
.
offsetParent
.
offsetParent
.
style
.
paddingLeft
;
if
(
originLeft
)
{
originLeft
=
originLeft
.
replace
(
/
[
a-zA-Z
]
/gi
,
''
);
}
else
{
originLeft
=
0
;
onResizeWidth
=
(
e
)
=>
{
const
originLeft
=
(
this
.
tableContainer
&&
this
.
tableContainer
.
getBoundingClientRect
().
x
)
||
0
;
if
(
this
.
widthHandle
)
{
this
.
widthHandle
.
style
.
left
=
`
${
e
.
x
-
originLeft
}
px`
;
}
this
.
setState
({
widthHandleLeft
:
e
.
x
-
originLeft
,
});
};
// 列伸缩开始
onResizeWidthStart
=
(
columnName
:
string
,
e
,
{
size
})
=>
{
let
originLeft
=
this
.
tableContainer
&&
this
.
tableContainer
.
offsetParent
.
offsetParent
.
offsetParent
.
style
.
paddingLeft
;
if
(
originLeft
)
{
originLeft
=
originLeft
.
replace
(
/
[
a-zA-Z
]
/gi
,
''
);
}
else
{
originLeft
=
0
;
onResizeWidthStart
=
(
e
)
=>
{
const
originLeft
=
(
this
.
tableContainer
&&
this
.
tableContainer
.
getBoundingClientRect
().
x
)
||
0
;
if
(
this
.
widthHandleWrapper
&&
this
.
widthHandle
)
{
this
.
widthHandleWrapper
.
style
.
display
=
'block'
;
this
.
widthHandle
.
style
.
left
=
`
${
e
.
x
-
originLeft
}
px`
;
}
this
.
setState
({
showWidthHandle
:
true
,
widthHandleLeft
:
e
.
x
-
originLeft
,
});
};
// 列伸缩结束
onResizeWidthStop
=
(
columnName
:
string
,
e
,
{
size
})
=>
{
...
...
@@ -256,10 +244,12 @@ export default class AirTable extends Component<TableProps, TableState> {
}
newColumns
.
push
(
item
);
});
if
(
this
.
widthHandleWrapper
)
{
this
.
widthHandleWrapper
.
style
.
display
=
'none'
;
}
this
.
setState
(
{
columns
:
newColumns
,
showWidthHandle
:
false
,
},
()
=>
{
this
.
grid1
&&
this
.
grid1
.
recomputeGridSize
();
...
...
@@ -301,8 +291,8 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
/>
}
// onResize={this.onResizeWidth.bind(this, columnName)
}
// onResizeStart={this.onResizeWidthStart.bind(this, columnName)
}
onResize=
{
this
.
onResizeWidth
}
onResizeStart=
{
this
.
onResizeWidthStart
}
onResizeStop=
{
this
.
onResizeWidthStop
.
bind
(
this
,
columnName
)
}
draggableOpts=
{
{
enableUserSelectHack
:
false
}
}
>
...
...
@@ -418,7 +408,7 @@ export default class AirTable extends Component<TableProps, TableState> {
render
()
{
const
{
loading
,
noDataPlaceholder
,
loadComp
}
=
this
.
props
;
const
{
columns
,
dataSource
,
tableWidth
=
0
,
tableHeight
=
0
,
showWidthHandle
,
widthHandleLeft
}
=
this
.
state
;
const
{
columns
,
dataSource
,
tableWidth
=
0
,
tableHeight
=
0
}
=
this
.
state
;
const
{
overscanColumnCount
,
overscanRowCount
,
rowHeight
,
headerHeight
}
=
this
.
config
;
const
scrollbarWidth
=
scrollbarSize
()
||
0
;
const
showColumns
=
this
.
memoizeColumns
(
columns
);
...
...
@@ -716,9 +706,16 @@ export default class AirTable extends Component<TableProps, TableState> {
</
div
>
<
div
className=
{
styles
.
widthHandleWrapper
}
style=
{
{
display
:
showWidthHandle
?
'block'
:
'none'
}
}
ref=
{
(
dom
)
=>
{
this
.
widthHandleWrapper
=
dom
;
}
}
>
<
div
className=
{
styles
.
widthHandle
}
style=
{
{
left
:
widthHandleLeft
}
}
/>
<
div
className=
{
styles
.
widthHandle
}
ref=
{
(
dom
)
=>
{
this
.
widthHandle
=
dom
;
}
}
/>
</
div
>
</
div
>
);
...
...
components/apolloTable/component/interface.tsx
View file @
9988d5e9
...
...
@@ -80,8 +80,6 @@ export interface TableState {
tableHeight
?:
number
;
tableWidth
?:
number
;
selectedCell
?:
any
;
showWidthHandle
:
boolean
;
widthHandleLeft
:
number
;
}
export
interface
CommonProps
extends
TableProps
{
operateConfig
?:
OperateConfigProps
;
...
...
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