personalizedrefrigerator / js-draw

Draw pictures using a pen, touchscreen, or mouse! JS-draw is a freehand drawing library for JavaScript and TypeScript.
https://personalizedrefrigerator.github.io/js-draw/typedoc/
MIT License
79 stars 8 forks source link

Dimension automatically set to `100` when the input field is empty. #58

Closed RechieKho closed 8 months ago

RechieKho commented 8 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when I set the dimension of the drawing. It automatically set to 100 as I clear the input field. This makes the process tedious as I need to make sure the input field to not evaluate to 0, like append a random non-zero number at the end of the dimension before I change the digit in front.

Describe the solution you'd like It is better to raise some sort of error below the input field when it is evaluated to 0. Such as:

Dimension cannot be 0px. It will default to 100px.

And then only when the input form is closed, it will default to 100px when the user input evaluate to 0.

Keep up the great work! This plugin is very likely to save my academic life! You are my saviour now.

personalizedrefrigerator commented 8 months ago

Thank you for reporting this!

Here's what's happening internally:

2ab8246632e048fbe169ab160f0c6709e12616fa should improve this by selecting changed digits at the beginning of the input.

For example, if trying to change width from 200 to 300, I might start by backspacing the 2. This still replaces the input's value with 100, but selects the 1 rather than allowing the selection to move to the end:

screenshot: 1 in 100 selected