Skip to content

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

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions