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

Events not sent when creating a "number" controller with both min() and max() called explicitely #55

Open
GoogleCodeExporter opened this issue Oct 30, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

create a controller on a number member of your object.
do not specify min or max there.
for eg: 
  var controller = gui.add(myObject, 'speed');

specify min and max after that:
  controller.min( 0 );      
  controller.max( 500 );

then register event listeners to it
  controller.onChange( function(value) { console.log("change"); } );
  controller.onFinishChange( function(value) { console.log("finishChange"); } );


The listeners should be called when the user changes the value but they're not.

The culprit is the max() method that in this context triggers reconstruction of 
the ui and breaks the event notifications.


I'm using Chrome on Windows 7 with dat.gui downloaded on the 21 dec. 2014.


Here is some code to reproduce the problem:
function MyObject(speed)
{
    this.speed = speed;
}

function reproduceBug()
{
    var datgui = new dat.GUI();
    var myObject = new MyObject(5);
    var controller = datgui.add(myObject, 'speed');
    controller.min( 0 );        
    controller.max( 500 );      
    controller.onChange( function(value) { console.log("change"); } );
    controller.onFinishChange( function(value) { console.log("finishChange"); } );
}

Original issue reported on code.google.com by [email protected] on 21 Dec 2014 at 2:34

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

No branches or pull requests

1 participant