Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
f4f781ec
Commit
f4f781ec
authored
Nov 13, 2016
by
杨奕
Committed by
GitHub
Nov 13, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1014 from furybean/slow-table-hover
Table: fix hover effect is slow when data > 200.
parents
392325dd
f27d4337
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
19 deletions
+39
-19
packages/table/src/table-body.js
packages/table/src/table-body.js
+38
-18
packages/table/src/table-column.js
packages/table/src/table-column.js
+1
-1
No files found.
packages/table/src/table-body.js
View file @
f4f781ec
import
{
getValueByPath
,
getCell
,
getColumnBy
Id
,
getColumnBy
Cell
}
from
'
./util
'
;
import
{
getValueByPath
,
getCell
,
getColumnByCell
}
from
'
./util
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -42,9 +42,7 @@ export default {
...
@@ -42,9 +42,7 @@ export default {
on
-
mouseenter
=
{
(
$event
)
=>
this
.
handleCellMouseEnter
(
$event
,
row
)
}
on
-
mouseenter
=
{
(
$event
)
=>
this
.
handleCellMouseEnter
(
$event
,
row
)
}
on
-
mouseleave
=
{
this
.
handleCellMouseLeave
}
>
on
-
mouseleave
=
{
this
.
handleCellMouseLeave
}
>
{
{
column
.
renderCell
column
.
renderCell
.
call
(
this
.
_renderProxy
,
h
,
{
row
,
column
,
$index
,
store
:
this
.
store
,
_self
:
this
.
$parent
.
$vnode
.
context
})
?
column
.
renderCell
.
call
(
this
.
_renderProxy
,
h
,
{
row
,
column
,
$index
,
store
:
this
.
store
,
_self
:
this
.
$parent
.
$vnode
.
context
})
:
<
div
class
=
"
cell
"
>
{
this
.
getCellContent
(
row
,
column
.
property
,
column
.
id
)
}
<
/div
>
}
}
<
/td
>
<
/td
>
)
)
...
@@ -60,15 +58,42 @@ export default {
...
@@ -60,15 +58,42 @@ export default {
);
);
},
},
watch
:
{
'
store.states.hoverRow
'
(
newVal
,
oldVal
)
{
const
el
=
this
.
$el
;
if
(
!
el
)
return
;
const
rows
=
el
.
querySelectorAll
(
'
tr
'
);
const
oldRow
=
rows
[
oldVal
];
const
newRow
=
rows
[
newVal
];
if
(
oldRow
)
{
oldRow
.
classList
.
remove
(
'
hover-row
'
);
}
if
(
newRow
)
{
newRow
.
classList
.
add
(
'
hover-row
'
);
}
},
'
store.states.currentRow
'
(
newVal
,
oldVal
)
{
if
(
!
this
.
highlight
)
return
;
const
el
=
this
.
$el
;
if
(
!
el
)
return
;
const
data
=
this
.
store
.
states
.
data
;
const
rows
=
el
.
querySelectorAll
(
'
tr
'
);
const
oldRow
=
rows
[
data
.
indexOf
(
oldVal
)];
const
newRow
=
rows
[
data
.
indexOf
(
newVal
)];
if
(
oldRow
)
{
oldRow
.
classList
.
remove
(
'
current-row
'
);
}
if
(
newRow
)
{
newRow
.
classList
.
add
(
'
current-row
'
);
}
}
},
computed
:
{
computed
:
{
data
()
{
data
()
{
return
this
.
store
.
states
.
data
;
return
this
.
store
.
states
.
data
;
},
},
hoverRowIndex
()
{
return
this
.
store
.
states
.
hoverRow
;
},
columnsCount
()
{
columnsCount
()
{
return
this
.
store
.
states
.
columns
.
length
;
return
this
.
store
.
states
.
columns
.
length
;
},
},
...
@@ -105,9 +130,6 @@ export default {
...
@@ -105,9 +130,6 @@ export default {
getRowClass
(
row
,
index
)
{
getRowClass
(
row
,
index
)
{
const
classes
=
[];
const
classes
=
[];
if
(
this
.
hoverRowIndex
===
index
)
{
classes
.
push
(
'
hover-row
'
);
}
const
rowClassName
=
this
.
rowClassName
;
const
rowClassName
=
this
.
rowClassName
;
if
(
typeof
rowClassName
===
'
string
'
)
{
if
(
typeof
rowClassName
===
'
string
'
)
{
...
@@ -116,11 +138,6 @@ export default {
...
@@ -116,11 +138,6 @@ export default {
classes
.
push
(
rowClassName
.
apply
(
null
,
[
row
,
index
])
||
''
);
classes
.
push
(
rowClassName
.
apply
(
null
,
[
row
,
index
])
||
''
);
}
}
const
currentRow
=
this
.
store
.
states
.
currentRow
;
if
(
this
.
highlight
&&
currentRow
===
row
)
{
classes
.
push
(
'
current-row
'
);
}
return
classes
.
join
(
'
'
);
return
classes
.
join
(
'
'
);
},
},
...
@@ -172,12 +189,15 @@ export default {
...
@@ -172,12 +189,15 @@ export default {
table
.
$emit
(
'
row-click
'
,
row
,
event
);
table
.
$emit
(
'
row-click
'
,
row
,
event
);
},
},
getCellContent
(
row
,
property
,
columnId
)
{
getCellContent
(
row
,
property
,
column
)
{
const
column
=
getColumnById
(
this
.
$parent
,
columnId
);
if
(
column
&&
column
.
formatter
)
{
if
(
column
&&
column
.
formatter
)
{
return
column
.
formatter
(
row
,
column
);
return
column
.
formatter
(
row
,
column
);
}
}
if
(
property
&&
property
.
indexOf
(
'
.
'
)
===
-
1
)
{
return
row
[
property
];
}
return
getValueByPath
(
row
,
property
);
return
getValueByPath
(
row
,
property
);
}
}
}
}
...
...
packages/table/src/table-column.js
View file @
f4f781ec
...
@@ -73,7 +73,7 @@ const getDefaultColumn = function(type, options) {
...
@@ -73,7 +73,7 @@ const getDefaultColumn = function(type, options) {
};
};
const
DEFAULT_RENDER_CELL
=
function
(
h
,
{
row
,
column
},
parent
)
{
const
DEFAULT_RENDER_CELL
=
function
(
h
,
{
row
,
column
},
parent
)
{
return
<
span
>
{
parent
.
getCellContent
(
row
,
column
.
property
,
column
.
id
)
}
<
/span>
;
return
parent
.
getCellContent
(
row
,
column
.
property
,
column
)
;
};
};
export
default
{
export
default
{
...
...
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