diff --git a/examples/lib/defaultHtmlStepUi.js b/examples/lib/defaultHtmlStepUi.js index 8928aa4e..6083cfcc 100644 --- a/examples/lib/defaultHtmlStepUi.js +++ b/examples/lib/defaultHtmlStepUi.js @@ -136,7 +136,7 @@ function DefaultHtmlStepUi(_sequencer, options) { '"max="' + inputDesc.max + '"step="' + - (inputDesc.step ? inputDesc.step : 1) + '">' + '' + paramVal + ''; + inputDesc.step + '">' + '' + paramVal + ''; } else html += '">'; diff --git a/examples/lib/mapHtmltypes.js b/examples/lib/mapHtmltypes.js index c7005d43..26add608 100644 --- a/examples/lib/mapHtmltypes.js +++ b/examples/lib/mapHtmltypes.js @@ -7,6 +7,7 @@ function mapHtmlTypes(inputInfo){ switch(inputInfo.type.toLowerCase()){ case 'integer': htmlType = inputInfo.min != undefined ? 'range' : 'number'; + if (htmlType === 'range') inputInfo.step = inputInfo.step || 1; // default range step size for integer break; case 'string': htmlType = 'text'; @@ -19,6 +20,7 @@ function mapHtmlTypes(inputInfo){ break; case 'float': htmlType = inputInfo.min != undefined ? 'range' : 'text'; + if (htmlType === 'range') inputInfo.step = inputInfo.step || 0.1; // default range step size for float break; default: htmlType = 'text'; diff --git a/test/ui/spec/mapHtmlTypes.spec.js b/test/ui/spec/mapHtmlTypes.spec.js index f413b3d2..a93e6ab0 100644 --- a/test/ui/spec/mapHtmlTypes.spec.js +++ b/test/ui/spec/mapHtmlTypes.spec.js @@ -6,10 +6,12 @@ describe('HTML Types Mapping Function', function() { expect(mapHtmlTypes({type: 'percentage'})).toEqual({type: 'number'}); expect(mapHtmlTypes({type: 'integer'})).toEqual({type: 'number'}); - expect(mapHtmlTypes({type: 'integer', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100}); + expect(mapHtmlTypes({type: 'integer', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 1}); + expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1}); // should default to step = 1 expect(mapHtmlTypes({type: 'float'})).toEqual({type: 'text'}); - expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100}); + expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1}); + expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1}); // should default to step = 0.1 }); it('maps text type', function() { @@ -21,4 +23,4 @@ describe('HTML Types Mapping Function', function() { expect(mapHtmlTypes({type: 'select'})).toEqual({type: 'select'}); }); -}); \ No newline at end of file +});