File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ export default class Header extends Component {
9999 this . props . showPeriod ( moment ( time - 0 ) , unit )
100100 }
101101 }
102-
102+
103103 shouldComponentUpdate ( nextProps ) {
104104 const willUpate =
105105 nextProps . canvasTimeStart != this . props . canvasTimeStart ||
@@ -143,6 +143,11 @@ export default class Header extends Component {
143143 )
144144
145145 const labelWidth = right - left
146+ // this width applies to the content in the header
147+ // it simulates stickyness where the content is fixed in the center
148+ // of the label. when the labelWidth is less than visible time range,
149+ // have label content fill the entire width
150+ const contentWidth = Math . min ( labelWidth , canvasWidth / 3 )
146151
147152 topHeaderLabels . push (
148153 < div
@@ -159,7 +164,9 @@ export default class Header extends Component {
159164 cursor : 'pointer'
160165 } }
161166 >
162- < span > { this . headerLabel ( time , nextUnit , labelWidth ) } </ span >
167+ < span style = { { width : contentWidth , display : 'block' } } >
168+ { this . headerLabel ( time , nextUnit , labelWidth ) }
169+ </ span >
163170 </ div >
164171 )
165172 }
You can’t perform that action at this time.
0 commit comments