sailingsumo / dat-gui

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

Allow using Object instead of property #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Problem:
No way to make gui-dat easily change jquery functions or css styles.
ie:
gui.add($("#div").css("z-index"),null);

There is no way to have a property in gui-dat if the object is a string.... But 
I might want this, and I will write my own "onchange": 

.onChange(function(v){
    $("#div").css("z-index",v);
});

The best would be to give gui-dat a property as a function to automatically 
change [like: gui.add($("#div"),css("z-index"));], but as per the above I 
changed the source code that if the property is null the get and set value are 
on the object and determining type to use object instead of property. ie:

line 2859:
dat.controllers.factory = (function (OptionController, NumberControllerBox, 
NumberControllerSlider, StringController, FunctionController, 
BooleanController, common) {
      return function(object, property) {
        var initialValue = object;
        if(property)
             initialValue = object[property];

The biggest issue here is the title uses the property name, but the other issue 
I filed would cover that anyway. Is there any likelihood this will be 
fixed/adjusted or should I try to write a simple non-reusable widget that will 
meet my needs?

Great tool and thank you.

Original issue reported on code.google.com by msj...@gmail.com on 27 Apr 2012 at 6:58