@@ -9,6 +9,9 @@ import DialogContentText from '@material-ui/core/DialogContentText';
9
9
import DialogTitle from '@material-ui/core/DialogTitle' ;
10
10
import FormGroup from '@material-ui/core/FormGroup' ;
11
11
import FormControlLabel from '@material-ui/core/FormControlLabel' ;
12
+ import FormLabel from '@material-ui/core/FormLabel' ;
13
+ import RadioGroup from '@material-ui/core/RadioGroup' ;
14
+ import Radio from '@material-ui/core/Radio' ;
12
15
import Switch from '@material-ui/core/Switch' ;
13
16
import Input from '@material-ui/core/Input' ;
14
17
import InputAdornment from '@material-ui/core/InputAdornment' ;
@@ -44,6 +47,20 @@ const styles = theme => ({
44
47
display : 'flex' ,
45
48
justifyContent : 'space-between' ,
46
49
} ,
50
+ group : {
51
+ marginTop : theme . spacing . unit * 1 ,
52
+ marginLeft : theme . spacing . unit * 0 ,
53
+ } ,
54
+ tweenPrecisionAbsoluteInput : {
55
+ marginTop : theme . spacing . unit * 1 ,
56
+ marginLeft : theme . spacing . unit * 1.5 ,
57
+ width : '6.9em' ,
58
+ } ,
59
+ tweenPrecisionRelativeInput : {
60
+ marginTop : theme . spacing . unit * 1 ,
61
+ marginLeft : theme . spacing . unit * 1.5 ,
62
+ width : '4.8em' ,
63
+ } ,
47
64
holdOffInput : {
48
65
width : '7.6em' ,
49
66
} ,
@@ -77,6 +94,22 @@ class SettingsDialog extends React.Component {
77
94
this . props . onTweenShapesSwitchChange ( event . target . checked ) ;
78
95
} ;
79
96
97
+ handleTweenPrecisionChange = ( event ) => {
98
+ let tweenPrecision = event . target . value ;
99
+ if ( event . target . value === 'absolute' || tweenPrecision > 1 ) {
100
+ tweenPrecision = Math . max ( Math . ceil ( tweenPrecision ) , 1 ) ;
101
+ }
102
+ this . props . onTweenPrecisionChange ( tweenPrecision . toString ( ) + ( this . props . tweenPrecision . includes ( '%' ) ? '%' : '' ) ) ;
103
+ } ;
104
+
105
+ handleTweenPrecisionIsRelativeRadioChange = ( event ) => {
106
+ let tweenPrecision = + this . props . tweenPrecision . split ( '%' ) [ 0 ] ;
107
+ if ( event . target . value === 'absolute' || tweenPrecision > 1 ) {
108
+ tweenPrecision = Math . max ( Math . ceil ( tweenPrecision ) , 1 ) ;
109
+ }
110
+ this . props . onTweenPrecisionChange ( tweenPrecision . toString ( ) + ( event . target . value === 'relative' ? '%' : '' ) ) ;
111
+ } ;
112
+
80
113
handleHoldOffChange = ( event ) => {
81
114
this . props . onHoldOffChange ( event . target . value ) ;
82
115
} ;
@@ -91,6 +124,13 @@ class SettingsDialog extends React.Component {
91
124
92
125
render ( ) {
93
126
const { classes } = this . props ;
127
+ const tweenPrecisionIsRelative = this . props . tweenPrecision . includes ( '%' ) ;
128
+ const tweenPrecision = + this . props . tweenPrecision . split ( '%' ) [ 0 ] ;
129
+ const tweenPrecisionType = tweenPrecisionIsRelative ? 'relative' : 'absolute' ;
130
+ const tweenPrecisionUnit = tweenPrecisionIsRelative ? '%' : 'points' ;
131
+ const enableTweenPrecisionSetting = this . props . tweenPaths || this . props . tweenShapes ;
132
+ const tweenPrecisionStep = ( tweenPrecisionIsRelative && tweenPrecision <= 1 ) ? 0.1 : 1 ;
133
+ const tweenPrecisionInputClass = tweenPrecisionIsRelative ? classes . tweenPrecisionRelativeInput : classes . tweenPrecisionAbsoluteInput ;
94
134
return (
95
135
< div >
96
136
< Dialog
@@ -172,6 +212,45 @@ class SettingsDialog extends React.Component {
172
212
label = "Enable shape tweening during transitions"
173
213
/>
174
214
</ FormGroup >
215
+ < FormControl component = "fieldset" className = { classes . formControl } >
216
+ < FormLabel component = "legend" > Tweening precision</ FormLabel >
217
+ < RadioGroup
218
+ name = "tweenPrecision"
219
+ className = { classes . group }
220
+ value = { tweenPrecisionType }
221
+ onChange = { this . handleTweenPrecisionIsRelativeRadioChange }
222
+ >
223
+ < FormControlLabel
224
+ className = { classes . formControlLabel }
225
+ value = "absolute"
226
+ disabled = { ! enableTweenPrecisionSetting }
227
+ control = { < Radio /> }
228
+ label = "Absolute"
229
+ />
230
+ < FormControlLabel
231
+ className = { classes . formControlLabel }
232
+ value = "relative"
233
+ disabled = { ! enableTweenPrecisionSetting }
234
+ control = { < Radio /> }
235
+ label = "Relative"
236
+ />
237
+ </ RadioGroup >
238
+ < Input
239
+ className = { tweenPrecisionInputClass }
240
+ id = "tween-precision"
241
+ type = "number"
242
+ value = { tweenPrecision }
243
+ disabled = { ! enableTweenPrecisionSetting }
244
+ onChange = { this . handleTweenPrecisionChange }
245
+ endAdornment = { < InputAdornment position = "end" > { tweenPrecisionUnit } </ InputAdornment > }
246
+ inputProps = { {
247
+ 'aria-label' : 'tweenPrecision' ,
248
+ min : tweenPrecisionStep ,
249
+ max : tweenPrecisionIsRelative ? 100 : 999 ,
250
+ step : tweenPrecisionStep ,
251
+ } }
252
+ />
253
+ </ FormControl >
175
254
</ DialogContent >
176
255
< DialogTitle id = "form-dialog-title" > Text Editor</ DialogTitle >
177
256
< DialogContent classes = { { root : classes . root } } >
0 commit comments