Skip to content

Commit 3fc02b7

Browse files
committed
Added user configuration of transition duration
Resolves #52.
1 parent 4c6c8ee commit 3fc02b7

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/Graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Graph extends React.Component {
153153
this.renderGraphReady = true;
154154
this.setZoomScale(1, true);
155155
this.graphviz
156-
.transition(() => d3_transition().duration(1000));
156+
.transition(() => d3_transition().duration(this.props.transitionDuration * 1000));
157157
this.props.onInitialized();
158158
}
159159
if (this.pendingUpdate) {

src/SettingsDialog.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const styles = theme => ({
4747
display: 'flex',
4848
justifyContent: 'space-between',
4949
},
50+
transitionDuration: {
51+
width: '7.6em',
52+
},
5053
group: {
5154
marginTop: theme.spacing.unit * 1,
5255
marginLeft: theme.spacing.unit * 0,
@@ -86,6 +89,10 @@ class SettingsDialog extends React.Component {
8689
this.props.onFitGraphSwitchChange(event.target.checked);
8790
};
8891

92+
handleTransitionDurationChange = (event) => {
93+
this.props.onTransitionDurationChange(event.target.value);
94+
};
95+
8996
handleTweenPathsSwitchChange = (event) => {
9097
this.props.onTweenPathsSwitchChange(event.target.checked);
9198
};
@@ -188,6 +195,26 @@ class SettingsDialog extends React.Component {
188195
label="Fit graph to available area"
189196
/>
190197
</FormGroup>
198+
<FormControl
199+
className={classes.formControl}
200+
aria-describedby="transition-duration-helper-text"
201+
>
202+
<InputLabel shrink={true}>Transition duration</InputLabel>
203+
<Input
204+
className={classes.transitionDuration}
205+
id="transition-duration"
206+
type="number"
207+
value={this.props.transitionDuration}
208+
onChange={this.handleTransitionDurationChange}
209+
endAdornment={<InputAdornment position="end"> seconds</InputAdornment>}
210+
inputProps={{
211+
'aria-label': 'transitionDuration',
212+
min: 0.1,
213+
max: 99,
214+
step: 0.1,
215+
}}
216+
/>
217+
</FormControl>
191218
<FormGroup row>
192219
<FormControlLabel
193220
className={classes.formControlLabel}

src/pages/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Index extends React.Component {
5454
mouseOperationsDialogIsOpen: false,
5555
aboutDialogIsOpen: false,
5656
fitGraph : localStorage.getItem('fitGraph') === 'true',
57+
transitionDuration: localStorage.getItem('transitionDuration') || 1,
5758
tweenPaths : localStorage.getItem('tweenPaths') !== 'false',
5859
tweenShapes : localStorage.getItem('tweenShapes') !== 'false',
5960
tweenPrecision : localStorage.getItem('tweenPrecision') || '1%',
@@ -183,6 +184,12 @@ class Index extends React.Component {
183184
});
184185
}
185186

187+
handleTransitionDurationChange = (transitionDuration) => {
188+
this.setPersistentState({
189+
transitionDuration: transitionDuration,
190+
});
191+
}
192+
186193
handleTweenPathsSwitchChange = (tweenPaths) => {
187194
this.setPersistentState({
188195
tweenPaths: tweenPaths,
@@ -420,11 +427,13 @@ class Index extends React.Component {
420427
open={this.state.settingsDialogIsOpen}
421428
engine={this.state.engine}
422429
fitGraph={this.state.fitGraph}
430+
transitionDuration={this.state.transitionDuration}
423431
tweenPaths={this.state.tweenPaths}
424432
tweenShapes={this.state.tweenShapes}
425433
tweenPrecision={this.state.tweenPrecision}
426434
onEngineSelectChange={this.handleEngineSelectChange}
427435
onFitGraphSwitchChange={this.handleFitGraphSwitchChange}
436+
onTransitionDurationChange={this.handleTransitionDurationChange}
428437
onTweenPathsSwitchChange={this.handleTweenPathsSwitchChange}
429438
onTweenShapesSwitchChange={this.handleTweenShapesSwitchChange}
430439
onTweenPrecisionChange={this.handleTweenPrecisionChange}
@@ -499,6 +508,7 @@ class Index extends React.Component {
499508
dotSrc={this.state.dotSrc}
500509
engine={this.state.engine}
501510
fit={this.state.fitGraph}
511+
transitionDuration={this.state.transitionDuration}
502512
tweenPaths={this.state.tweenPaths}
503513
tweenShapes={this.state.tweenShapes}
504514
tweenPrecision={this.state.tweenPrecision}

0 commit comments

Comments
 (0)