cdotyone / mochaui

development tree for MochaUI
http://mochaui.org/demo/
Other
290 stars 83 forks source link

window.resize() "centered" option correction #106

Closed partikule closed 13 years ago

partikule commented 13 years ago

Symptom : When using resize() on a window from an external call, with "centered" option to true and just the "top" option set (for exemple) the window isn't centered correctly.

Reason : The type of options.top, options.left is not detected correctly.

Correction : In window.js, function resize, replace :

        if (options.centered){
            top = typeof(options.top) != 'undefined' ? options.top : oldTop - ((options.height - oldHeight) * .5);
            left = typeof(options.left) != 'undefined' ? options.left : oldLeft - ((options.width - oldWidth) * .5);
        } else {
            top = typeof(options.top) != 'undefined' ? options.top : oldTop;
            left = typeof(options.left) != 'undefined' ? options.left : oldLeft;
        }

by :

        if (options.centered){
            top = typeOf(options.top) != 'null' ? options.top : oldTop - ((options.height - oldHeight) * .5);
            left = typeOf(options.left) != 'null' ? options.left : oldLeft - ((options.width - oldWidth) * .5);
        } else {
            top = typeOf(options.top) != 'null' ? options.top : oldTop;
            left = typeOf(options.left) != 'null' ? options.left : oldLeft;
        }
cdotyone commented 13 years ago

Will look into this. Thanks for the fix.

cdotyone commented 13 years ago

Added to develop branch. Thanks for code.