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
773ae92e
Commit
773ae92e
authored
May 17, 2019
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rm redundant window.addEventListener
parent
602814cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
68 deletions
+2
-68
src/components/Charts/Bar/index.js
src/components/Charts/Bar/index.js
+0
-55
src/components/Charts/TagCloud/index.js
src/components/Charts/TagCloud/index.js
+2
-13
No files found.
src/components/Charts/Bar/index.js
View file @
773ae92e
import
React
,
{
Component
}
from
'
react
'
;
import
{
Chart
,
Axis
,
Tooltip
,
Geom
}
from
'
bizcharts
'
;
import
Debounce
from
'
lodash-decorators/debounce
'
;
import
Bind
from
'
lodash-decorators/bind
'
;
import
ResizeObserver
from
'
resize-observer-polyfill
'
;
import
styles
from
'
../index.less
'
;
class
Bar
extends
Component
{
...
...
@@ -11,14 +8,6 @@ class Bar extends Component {
autoHideXLabels
:
false
,
};
componentDidMount
()
{
window
.
addEventListener
(
'
resize
'
,
this
.
resize
,
{
passive
:
true
});
}
componentWillUnmount
()
{
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
}
handleRoot
=
n
=>
{
this
.
root
=
n
;
};
...
...
@@ -27,50 +16,6 @@ class Bar extends Component {
this
.
node
=
n
;
};
resizeObserver
()
{
const
ro
=
new
ResizeObserver
(
entries
=>
{
const
{
width
,
height
}
=
entries
[
0
].
contentRect
;
this
.
setState
(
preState
=>
{
if
(
preState
.
width
!==
width
||
preState
.
height
!==
height
)
{
return
{
height
,
};
}
return
null
;
});
});
if
(
this
.
root
)
{
ro
.
observe
(
this
.
root
);
}
}
@
Bind
()
@
Debounce
(
400
)
resize
()
{
if
(
!
this
.
node
)
{
return
;
}
const
canvasWidth
=
this
.
node
.
parentNode
.
clientWidth
;
const
{
data
=
[],
autoLabel
=
true
}
=
this
.
props
;
if
(
!
autoLabel
)
{
return
;
}
const
minWidth
=
data
.
length
*
30
;
const
{
autoHideXLabels
}
=
this
.
state
;
if
(
canvasWidth
<=
minWidth
)
{
if
(
!
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
true
,
});
}
}
else
if
(
autoHideXLabels
)
{
this
.
setState
({
autoHideXLabels
:
false
,
});
}
}
render
()
{
const
{
height
:
propsHeight
,
...
...
src/components/Charts/TagCloud/index.js
View file @
773ae92e
...
...
@@ -19,11 +19,8 @@ class TagCloud extends Component {
};
componentDidMount
()
{
requestAnimationFrame
(()
=>
{
this
.
initTagCloud
();
this
.
renderChart
();
});
window
.
addEventListener
(
'
resize
'
,
this
.
resize
,
{
passive
:
true
});
this
.
initTagCloud
();
this
.
renderChart
();
}
componentDidUpdate
(
preProps
)
{
...
...
@@ -35,16 +32,8 @@ class TagCloud extends Component {
componentWillUnmount
()
{
this
.
isUnmount
=
true
;
window
.
cancelAnimationFrame
(
this
.
requestRef
);
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
}
resize
=
()
=>
{
this
.
requestRef
=
requestAnimationFrame
(()
=>
{
this
.
renderChart
();
});
};
saveRootRef
=
node
=>
{
this
.
root
=
node
;
};
...
...
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