Adjust time picker spacing
parent
8f2513623b
commit
5051057f72
|
@ -6,6 +6,7 @@ import Hand from './hand';
|
|||
|
||||
const outerNumbers = [0, ...utils.range(13, 24)];
|
||||
const innerNumbers = [12, ...utils.range(1, 12)];
|
||||
const innerSpacing = 1.7;
|
||||
const step = 360 / 12;
|
||||
|
||||
export default React.createClass({
|
||||
|
@ -27,7 +28,7 @@ export default React.createClass({
|
|||
},
|
||||
|
||||
onHandMove (degrees, radius) {
|
||||
let currentInner = radius < this.props.radius - this.props.spacing * 2;
|
||||
let currentInner = radius < this.props.radius - this.props.spacing * innerSpacing;
|
||||
if (this.props.format === '24hr' && this.state.inner !== currentInner) {
|
||||
this.setState({inner: currentInner}, () => {
|
||||
this.props.onChange(this.valueFromDegrees(degrees));
|
||||
|
@ -83,10 +84,10 @@ export default React.createClass({
|
|||
twoDigits={is24hr}
|
||||
active={is24hr ? selected : (selected % 12 || 12)}
|
||||
/>
|
||||
{ this.renderInnerFace(radius - spacing * 2) }
|
||||
{ this.renderInnerFace(radius - spacing * innerSpacing) }
|
||||
<Hand ref='hand'
|
||||
angle={selected * step}
|
||||
length={(this.state.inner ? radius - spacing * 2 : radius) - spacing}
|
||||
length={(this.state.inner ? radius - spacing * innerSpacing : radius) - spacing}
|
||||
onMove={this.onHandMove}
|
||||
onMoved={onHandMoved}
|
||||
origin={center}
|
||||
|
|
|
@ -94,7 +94,7 @@ export default React.createClass({
|
|||
onChange={this.onHourChange}
|
||||
radius={this.state.radius}
|
||||
selected={this.state.time.getHours()}
|
||||
spacing={this.state.radius * 0.16}
|
||||
spacing={this.state.radius * 0.18}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
@ -106,7 +106,7 @@ export default React.createClass({
|
|||
onChange={this.onMinuteChange}
|
||||
radius={this.state.radius}
|
||||
selected={this.state.time.getMinutes()}
|
||||
spacing={this.state.radius * 0.16}
|
||||
spacing={this.state.radius * 0.18}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ export default React.createClass({
|
|||
<DatePicker value={datetime} />
|
||||
|
||||
<TimePicker />
|
||||
<TimePicker value={datetime} />
|
||||
<TimePicker value={datetime} format='ampm' />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue