Skip to content

Commit 0654aa2

Browse files
Merge pull request #1184 from suppermancool/f2f-30069264-issue-1055
fix issue #1055
2 parents c207fbf + c3002b4 commit 0654aa2

File tree

1 file changed

+18
-3
lines changed
  • src/shared/components/ProfilePage/Stats/HistoryGraph

1 file changed

+18
-3
lines changed

src/shared/components/ProfilePage/Stats/HistoryGraph/index.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default class HistoryGraph extends React.Component {
1111
constructor(props) {
1212
super(props);
1313
this.state = {};
14+
this.mobileWidth = 0;
1415
this.graphRef = React.createRef();
1516
}
1617

@@ -19,7 +20,9 @@ export default class HistoryGraph extends React.Component {
1920
$scope.desktop = window.innerWidth >= 900;
2021
this.draw();
2122
this.resizeHandle = () => {
22-
if (window.innerWidth < 900 && $scope.desktop) {
23+
if (window.innerWidth < 900
24+
&& ($scope.desktop
25+
|| (this.mobileWidth !== HistoryGraph.getMobileWidthGrapthMeasurements()))) {
2326
$scope.desktop = false;
2427
this.draw();
2528
} else if (window.innerWidth >= 900 && !$scope.desktop) {
@@ -46,6 +49,13 @@ export default class HistoryGraph extends React.Component {
4649
document.body.removeEventListener('click', this.bodyClickHandle);
4750
}
4851

52+
static getMobileWidthGrapthMeasurements() {
53+
if (window.innerWidth < 400) {
54+
return 200;
55+
}
56+
return 300;
57+
}
58+
4959
draw() {
5060
const $scope = this;
5161
const { history: wrapper } = this.props;
@@ -80,7 +90,7 @@ export default class HistoryGraph extends React.Component {
8090
};
8191

8292
const mobileMeasurements = {
83-
w: 300,
93+
w: 0,
8494
h: 200,
8595
padding: {
8696
top: 10,
@@ -91,7 +101,12 @@ export default class HistoryGraph extends React.Component {
91101
};
92102

93103
d3.select($scope.graphRef.current).select('svg').remove();
94-
const { w, h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
104+
let { w } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
105+
const { h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
106+
if (!$scope.desktop) {
107+
w = HistoryGraph.getMobileWidthGrapthMeasurements();
108+
this.mobileWidth = w;
109+
}
95110
const totalH = h + padding.top + padding.bottom;
96111

97112
const x = d3.time.scale()

0 commit comments

Comments
 (0)