ShannonZ / dat-gui

Automatically exported from code.google.com/p/dat-gui
0 stars 0 forks source link

Setting step on a controller doesn't set the impliedStep #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. gui.add(object, 'property').step(0.01), where property is initially a larger 
number i.e. 1.5
2. Attempting to scroll the value (by dragging the mouse up and down) results 
in 0.1 steps
3. Typing in manually allows 0.05 to be specified.

What is the expected output? What do you see instead?
I expect the draggable steps to be of 0.01 e.g. 1.5 -> 1.49 -> 1.48 etc

What version of the product are you using? On what operating system?
dat-gui v0.5
Chrome Version 24.0.1312.57 m
Win 7 

Please provide any additional information below.

This seems to be based on the impliedStep set by the algorithm. I couldn't see 
a way to set the step on creation of the controller.
I believe it would be fixed by this:

        /**
         * Specify a step value that dat.controllers.NumberController
         * increments by.
         *
         * @param {Number} stepValue The step value for
         * dat.controllers.NumberController
         * @default if minimum and maximum specified increment is 1% of the
         * difference otherwise stepValue is 1
         * @returns {dat.controllers.NumberController} this
         */
        step: function(v) {
          this.__step = v;
          this.__impliedStep = v;
          this.__precision = numDecimals(v);
          return this;
        }

Original issue reported on code.google.com by ianballa...@turbulenz.biz on 20 Feb 2013 at 5:48

GoogleCodeExporter commented 9 years ago
Just tested this and it works for me - thanks!

Original comment by aaron.b...@gmail.com on 7 Dec 2013 at 7:10

GoogleCodeExporter commented 9 years ago
In patch form against the dat.gui repo this is:

diff --git a/src/dat/controllers/NumberController.js 
b/src/dat/controllers/NumberController.js
index a589bf4..294e36c 100644
--- a/src/dat/controllers/NumberController.js
+++ b/src/dat/controllers/NumberController.js
@@ -122,6 +122,8 @@ define([
          */
         step: function(v) {
           this.__step = v;
+          this.__impliedStep = v;
+          this.__precision = numDecimals(v);
           return this;
         }

Original comment by aaron.b...@gmail.com on 7 Dec 2013 at 7:10

GoogleCodeExporter commented 9 years ago
Completely forgot about this issue. Thanks for trying it. Are you going to 
submit the patch?

Original comment by ianballa...@turbulenz.biz on 8 Dec 2013 at 12:12

GoogleCodeExporter commented 9 years ago
Couldn't find guidance on how to submit, there aren't pull requests. Any ideas?

Original comment by aaron.b...@gmail.com on 8 Dec 2013 at 6:02

GoogleCodeExporter commented 9 years ago
Yeah, sorry not quite sure what the process is. I suppose you could ask one of 
the owners. 

Original comment by ianballa...@turbulenz.biz on 9 Dec 2013 at 10:24

GoogleCodeExporter commented 9 years ago
Got hold of one of the owners on twitter:
https://twitter.com/jonobr1/status/410213149543911424

‏jonobr1:
@airburst you are absolutely correct on that! My apologies. I'll get this 
squared away in the next couple of days. Hold tight!

Original comment by aaron.b...@gmail.com on 10 Dec 2013 at 1:21

GoogleCodeExporter commented 9 years ago
Good news, it's back on github at https://github.com/dataarts/dat.gui

jonobr1 (@jonobr1) tweeted at 7:01 PM on Wed, Dec 18, 2013:
@airburst sorry for the delay. Github and Google Code are now mirrors and all 
issues and Pull Requests will be redirected to Github.

Original comment by aaron.b...@gmail.com on 19 Dec 2013 at 1:38

GoogleCodeExporter commented 9 years ago
Pull request at https://github.com/dataarts/dat.gui/pull/31

Original comment by aaron.b...@gmail.com on 19 Dec 2013 at 1:55

GoogleCodeExporter commented 9 years ago
Now accepted and applied to codebase. Won't appear in the main js file until 
they build. 
https://github.com/dataarts/dat.gui/commit/1cb6eca274eae229915f386b7798ea19cf2a0
217

Original comment by aaron.b...@gmail.com on 19 Dec 2013 at 2:21