@@ -11,6 +11,7 @@ export default class HistoryGraph extends React.Component {
11
11
constructor ( props ) {
12
12
super ( props ) ;
13
13
this . state = { } ;
14
+ this . mobileWidth = 0 ;
14
15
this . graphRef = React . createRef ( ) ;
15
16
}
16
17
@@ -19,7 +20,9 @@ export default class HistoryGraph extends React.Component {
19
20
$scope . desktop = window . innerWidth >= 900 ;
20
21
this . draw ( ) ;
21
22
this . resizeHandle = ( ) => {
22
- if ( window . innerWidth < 900 && $scope . desktop ) {
23
+ if ( window . innerWidth < 900
24
+ && ( $scope . desktop
25
+ || ( this . mobileWidth !== HistoryGraph . getMobileWidthGrapthMeasurements ( ) ) ) ) {
23
26
$scope . desktop = false ;
24
27
this . draw ( ) ;
25
28
} else if ( window . innerWidth >= 900 && ! $scope . desktop ) {
@@ -46,6 +49,13 @@ export default class HistoryGraph extends React.Component {
46
49
document . body . removeEventListener ( 'click' , this . bodyClickHandle ) ;
47
50
}
48
51
52
+ static getMobileWidthGrapthMeasurements ( ) {
53
+ if ( window . innerWidth < 400 ) {
54
+ return 200 ;
55
+ }
56
+ return 300 ;
57
+ }
58
+
49
59
draw ( ) {
50
60
const $scope = this ;
51
61
const { history : wrapper } = this . props ;
@@ -80,7 +90,7 @@ export default class HistoryGraph extends React.Component {
80
90
} ;
81
91
82
92
const mobileMeasurements = {
83
- w : 300 ,
93
+ w : 0 ,
84
94
h : 200 ,
85
95
padding : {
86
96
top : 10 ,
@@ -91,7 +101,12 @@ export default class HistoryGraph extends React.Component {
91
101
} ;
92
102
93
103
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
+ }
95
110
const totalH = h + padding . top + padding . bottom ;
96
111
97
112
const x = d3 . time . scale ( )
0 commit comments