Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
388d804e
Commit
388d804e
authored
Apr 25, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maybe useful performance optimization
parent
62e77dea
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
74 deletions
+105
-74
src/components/ActiveChart/index.js
src/components/ActiveChart/index.js
+16
-7
src/components/Charts/Bar/index.js
src/components/Charts/Bar/index.js
+17
-15
src/components/Charts/Pie/index.js
src/components/Charts/Pie/index.js
+20
-15
src/components/Charts/Radar/index.js
src/components/Charts/Radar/index.js
+3
-1
src/components/Charts/TagCloud/index.js
src/components/Charts/TagCloud/index.js
+7
-3
src/components/Charts/WaterWave/index.js
src/components/Charts/WaterWave/index.js
+10
-7
src/routes/Account/Settings/Info.js
src/routes/Account/Settings/Info.js
+12
-10
src/routes/Forms/AdvancedForm.js
src/routes/Forms/AdvancedForm.js
+7
-5
src/routes/Profile/AdvancedProfile.js
src/routes/Profile/AdvancedProfile.js
+13
-11
No files found.
src/components/ActiveChart/index.js
View file @
388d804e
...
@@ -26,17 +26,26 @@ export default class ActiveChart extends Component {
...
@@ -26,17 +26,26 @@ export default class ActiveChart extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
this
.
timer
=
setInterval
(()
=>
{
this
.
loopData
();
this
.
setState
({
activeData
:
getActiveData
(),
});
},
1000
);
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
clear
Interval
(
this
.
timer
);
clear
Timeout
(
this
.
timer
);
}
}
loopData
=
()
=>
{
this
.
timer
=
setTimeout
(()
=>
{
this
.
setState
(
{
activeData
:
getActiveData
(),
},
()
=>
{
requestAnimationFrame
(()
=>
{
this
.
loopData
();
});
}
);
},
1000
);
};
render
()
{
render
()
{
const
{
activeData
=
[]
}
=
this
.
state
;
const
{
activeData
=
[]
}
=
this
.
state
;
...
...
src/components/Charts/Bar/index.js
View file @
388d804e
...
@@ -25,25 +25,27 @@ class Bar extends Component {
...
@@ -25,25 +25,27 @@ class Bar extends Component {
if
(
!
this
.
node
)
{
if
(
!
this
.
node
)
{
return
;
return
;
}
}
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
requestAnimationFrame
(()
=>
{
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
if
(
!
autoLabel
)
{
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
return
;
if
(
!
autoLabel
)
{
}
return
;
const
minWidth
=
data
.
length
*
30
;
}
const
{
autoHideXLabels
}
=
this
.
state
;
const
minWidth
=
data
.
length
*
30
;
const
{
autoHideXLabels
}
=
this
.
state
;
if
(
canvasWidth
<=
minWidth
)
{
if
(
canvasWidth
<=
minWidth
)
{
if
(
!
autoHideXLabels
)
{
if
(
!
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
true
,
});
}
}
else
if
(
autoHideXLabels
)
{
this
.
setState
({
this
.
setState
({
autoHideXLabels
:
tru
e
,
autoHideXLabels
:
fals
e
,
});
});
}
}
}
else
if
(
autoHideXLabels
)
{
});
this
.
setState
({
autoHideXLabels
:
false
,
});
}
}
}
handleRoot
=
n
=>
{
handleRoot
=
n
=>
{
...
...
src/components/Charts/Pie/index.js
View file @
388d804e
...
@@ -19,8 +19,6 @@ export default class Pie extends Component {
...
@@ -19,8 +19,6 @@ export default class Pie extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
this
.
getLegendData
();
this
.
resize
();
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
}
}
...
@@ -46,12 +44,17 @@ export default class Pie extends Component {
...
@@ -46,12 +44,17 @@ export default class Pie extends Component {
getG2Instance
=
chart
=>
{
getG2Instance
=
chart
=>
{
this
.
chart
=
chart
;
this
.
chart
=
chart
;
requestAnimationFrame
(()
=>
{
this
.
getLegendData
();
this
.
resize
();
});
};
};
// for custom lengend view
// for custom lengend view
getLegendData
=
()
=>
{
getLegendData
=
()
=>
{
if
(
!
this
.
chart
)
return
;
if
(
!
this
.
chart
)
return
;
const
geom
=
this
.
chart
.
getAllGeoms
()[
0
];
// θ·εζζηεΎε½’
const
geom
=
this
.
chart
.
getAllGeoms
()[
0
];
// θ·εζζηεΎε½’
if
(
!
geom
)
return
;
const
items
=
geom
.
get
(
'
dataArray
'
)
||
[];
// θ·εεΎε½’ε―ΉεΊη
const
items
=
geom
.
get
(
'
dataArray
'
)
||
[];
// θ·εεΎε½’ε―ΉεΊη
const
legendData
=
items
.
map
(
item
=>
{
const
legendData
=
items
.
map
(
item
=>
{
...
@@ -71,22 +74,24 @@ export default class Pie extends Component {
...
@@ -71,22 +74,24 @@ export default class Pie extends Component {
@
Bind
()
@
Bind
()
@
Debounce
(
300
)
@
Debounce
(
300
)
resize
()
{
resize
()
{
const
{
hasLegend
}
=
this
.
props
;
requestAnimationFrame
(()
=>
{
if
(
!
hasLegend
||
!
this
.
root
)
{
const
{
hasLegend
}
=
this
.
props
;
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
if
(
!
hasLegend
||
!
this
.
root
)
{
return
;
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
}
return
;
if
(
this
.
root
.
parentNode
.
clientWidth
<=
380
)
{
}
if
(
!
this
.
state
.
legendBlock
)
{
if
(
this
.
root
.
parentNode
.
clientWidth
<=
380
)
{
if
(
!
this
.
state
.
legendBlock
)
{
this
.
setState
({
legendBlock
:
true
,
});
}
}
else
if
(
this
.
state
.
legendBlock
)
{
this
.
setState
({
this
.
setState
({
legendBlock
:
tru
e
,
legendBlock
:
fals
e
,
});
});
}
}
}
else
if
(
this
.
state
.
legendBlock
)
{
});
this
.
setState
({
legendBlock
:
false
,
});
}
}
}
handleRoot
=
n
=>
{
handleRoot
=
n
=>
{
...
...
src/components/Charts/Radar/index.js
View file @
388d804e
...
@@ -12,7 +12,9 @@ export default class Radar extends Component {
...
@@ -12,7 +12,9 @@ export default class Radar extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
this
.
getLengendData
();
requestAnimationFrame
(()
=>
{
this
.
getLengendData
();
});
}
}
componentWillReceiveProps
(
nextProps
)
{
componentWillReceiveProps
(
nextProps
)
{
...
...
src/components/Charts/TagCloud/index.js
View file @
388d804e
...
@@ -19,8 +19,10 @@ class TagCloud extends Component {
...
@@ -19,8 +19,10 @@ class TagCloud extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
this
.
initTagCloud
();
requestAnimationFrame
(()
=>
{
this
.
renderChart
();
this
.
initTagCloud
();
this
.
renderChart
();
});
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
}
}
...
@@ -36,7 +38,9 @@ class TagCloud extends Component {
...
@@ -36,7 +38,9 @@ class TagCloud extends Component {
}
}
resize
=
()
=>
{
resize
=
()
=>
{
this
.
renderChart
();
requestAnimationFrame
(()
=>
{
this
.
renderChart
();
});
};
};
saveRootRef
=
node
=>
{
saveRootRef
=
node
=>
{
...
...
src/components/Charts/WaterWave/index.js
View file @
388d804e
...
@@ -13,9 +13,10 @@ export default class WaterWave extends PureComponent {
...
@@ -13,9 +13,10 @@ export default class WaterWave extends PureComponent {
};
};
componentDidMount
()
{
componentDidMount
()
{
this
.
renderChart
();
requestAnimationFrame
(()
=>
{
this
.
resize
();
this
.
renderChart
();
this
.
resize
();
});
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
}
}
...
@@ -28,10 +29,12 @@ export default class WaterWave extends PureComponent {
...
@@ -28,10 +29,12 @@ export default class WaterWave extends PureComponent {
}
}
resize
=
()
=>
{
resize
=
()
=>
{
const
{
height
}
=
this
.
props
;
requestAnimationFrame
(()
=>
{
const
{
offsetWidth
}
=
this
.
root
.
parentNode
;
const
{
height
}
=
this
.
props
;
this
.
setState
({
const
{
offsetWidth
}
=
this
.
root
.
parentNode
;
radio
:
offsetWidth
<
height
?
offsetWidth
/
height
:
1
,
this
.
setState
({
radio
:
offsetWidth
<
height
?
offsetWidth
/
height
:
1
,
});
});
});
};
};
...
...
src/routes/Account/Settings/Info.js
View file @
388d804e
...
@@ -52,16 +52,18 @@ export default class Info extends Component {
...
@@ -52,16 +52,18 @@ export default class Info extends Component {
if
(
!
this
.
main
)
{
if
(
!
this
.
main
)
{
return
;
return
;
}
}
let
mode
=
'
inline
'
;
requestAnimationFrame
(()
=>
{
const
{
offsetWidth
}
=
this
.
main
;
let
mode
=
'
inline
'
;
if
(
this
.
main
.
offsetWidth
<
641
&&
offsetWidth
>
400
)
{
const
{
offsetWidth
}
=
this
.
main
;
mode
=
'
horizontal
'
;
if
(
this
.
main
.
offsetWidth
<
641
&&
offsetWidth
>
400
)
{
}
mode
=
'
horizontal
'
;
if
(
window
.
innerWidth
<
768
&&
offsetWidth
>
400
)
{
}
mode
=
'
horizontal
'
;
if
(
window
.
innerWidth
<
768
&&
offsetWidth
>
400
)
{
}
mode
=
'
horizontal
'
;
this
.
setState
({
}
mode
,
this
.
setState
({
mode
,
});
});
});
};
};
render
()
{
render
()
{
...
...
src/routes/Forms/AdvancedForm.js
View file @
388d804e
...
@@ -68,11 +68,13 @@ class AdvancedForm extends PureComponent {
...
@@ -68,11 +68,13 @@ class AdvancedForm extends PureComponent {
window
.
removeEventListener
(
'
resize
'
,
this
.
resizeFooterToolbar
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resizeFooterToolbar
);
}
}
resizeFooterToolbar
=
()
=>
{
resizeFooterToolbar
=
()
=>
{
const
sider
=
document
.
querySelectorAll
(
'
.ant-layout-sider
'
)[
0
];
requestAnimationFrame
(()
=>
{
const
width
=
`calc(100% -
${
sider
.
style
.
width
}
)`
;
const
sider
=
document
.
querySelectorAll
(
'
.ant-layout-sider
'
)[
0
];
if
(
this
.
state
.
width
!==
width
)
{
const
width
=
`calc(100% -
${
sider
.
style
.
width
}
)`
;
this
.
setState
({
width
});
if
(
this
.
state
.
width
!==
width
)
{
}
this
.
setState
({
width
});
}
});
};
};
render
()
{
render
()
{
const
{
form
,
dispatch
,
submitting
}
=
this
.
props
;
const
{
form
,
dispatch
,
submitting
}
=
this
.
props
;
...
...
src/routes/Profile/AdvancedProfile.js
View file @
388d804e
...
@@ -212,17 +212,19 @@ export default class AdvancedProfile extends Component {
...
@@ -212,17 +212,19 @@ export default class AdvancedProfile extends Component {
@
Bind
()
@
Bind
()
@
Debounce
(
200
)
@
Debounce
(
200
)
setStepDirection
()
{
setStepDirection
()
{
const
{
stepDirection
}
=
this
.
state
;
requestAnimationFrame
(()
=>
{
const
w
=
getWindowWidth
();
const
{
stepDirection
}
=
this
.
state
;
if
(
stepDirection
!==
'
vertical
'
&&
w
<=
576
)
{
const
w
=
getWindowWidth
();
this
.
setState
({
if
(
stepDirection
!==
'
vertical
'
&&
w
<=
576
)
{
stepDirection
:
'
vertical
'
,
this
.
setState
({
});
stepDirection
:
'
vertical
'
,
}
else
if
(
stepDirection
!==
'
horizontal
'
&&
w
>
576
)
{
});
this
.
setState
({
}
else
if
(
stepDirection
!==
'
horizontal
'
&&
w
>
576
)
{
stepDirection
:
'
horizontal
'
,
this
.
setState
({
});
stepDirection
:
'
horizontal
'
,
}
});
}
});
}
}
render
()
{
render
()
{
...
...
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