playcanvas / pcui

UI component library for web-based tools
http://playcanvas.github.io/pcui
MIT License
664 stars 63 forks source link

[Breaking] Numeric input to use shift for precision when using arrow keys or dragging #187

Closed yaustar closed 1 year ago

yaustar commented 1 year ago

Related ticket: https://github.com/playcanvas/editor/issues/912 where some users (ie me!) would use the dragger for precision over large changes.

This commit adds holding the shift modifier to use a step precision value instead of step for dragging.

This is a breaking change where we've inverted the behaviour (that's not commonly used) for holding shift. It used to apply a 10x scale to step amount where arrows where used to change the values.

The approach we are going for now is that step should be a 'reasonable' to change the number value by default given its use case and holding shift will give precision.

The stepPrecision is defaulted to step * 0.1 but can be customised on a per input basis to be something else if we choose to.

This is a breaking change but it's not common to use the arrow keys to change values let alone, holding shift as a modifier so it should be fairly safe to do.

I opted for adding a stepPrecision property over a default scale (such as 0.1) to allow us to have more customisability on the Editor side in the cases where the factor doesn't fit the usecase.