Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-linear increments #3

Open
VororRich opened this issue Oct 21, 2017 · 2 comments
Open

Non-linear increments #3

VororRich opened this issue Oct 21, 2017 · 2 comments

Comments

@VororRich
Copy link
Contributor

Scenario - I'm wanting a knob where I can select every (whole) number between 0 and 720.

Problem - It doesn't seem to be possible to set values causing the step increments to be 1.

Reproduction - With a starting setup as follows...

[min]="0" [max]="720" [startDegree]="0" [endDegree]="360" (change)="log($event)"

I would have expected each "step" of the knob to be 2 (i.e. 720/360). However, in testing, this gives increase in output value of 6. Assuming this to be graphical precision due to the size of the knob, I expected that Increasing the [endDegree] to "720" (i.e. 2 full rotations), each "step" of the knob would now be 3. However, the step is still 6, the knob instead just moves twice as far (i.e. 2 degrees). This can be more clearly seen by setting [endDegree] to "3600" (i.e. 10 full rotations). The step is still 6 but the knob rotation occurs in very large jumps.

I'll have a work through the maths and submit a pull request if I figure anything out.

@VororRich
Copy link
Contributor Author

I think it comes down to the constructor and the calculation of maxDistance. I can kinda see why the code is there (though I'm not sure why this.maxDistance = Math.round((this.maxDistance * 10) / 100); isnt just this.maxDistance = Math.round(this.maxDistance / 10);?).

Perhaps one approach would be to have pixel based rotation (boolean @input flag)? So 1 pixel of mouse movement is +/- 1 meterValue? That would allow the user precise knob values whereas at the moment, the precision is determined by screen width.

@spheras
Copy link
Owner

spheras commented Oct 24, 2017

Hello.
First: Of course Math.round((this.maxDistance * 10) / 100) == Math.round(this.maxDistance / 10)
😆
It was just an initial calculation, and it is still there.

Second: this is done mainly for "small" screens. ie, I use it in an ionic app for mobile devices, but not only, It seems reasonable to calculate a (more or less) physical distance and put in relation with the total degrees you can move. This way, the calculated distance (maxDistance=10% of your screen) is the correlation for the maximum degrees you can move. If you put 1 pixel for 1 degree correlation, then you will need to move 1 pixel for each degree, and it depends on the screen if this is a reasonable distance or not. ie, if you configure a knob with 10 degrees, you only move 10 pixels?? Think in a touch movement, is much more difficult, you need a good distance to be precise.. in fact, now this distance is small (I think it should be a 20% or 30%), but too much distance could be hard for mouse users... it depends.

Third: What we can do is to put the % of the distance in a configuration variable (now is 10, but you can put 50%, 100%, whatever).. or even, just put the distance in pixels in a variable (you know, in case this variable is filled, then don't calculate the % of the screen, and just put the number of pixels you want to move for the knob).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants