cdotyone / mochaui

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

Bug in resizeWindow #12

Closed mui-org closed 14 years ago

mui-org commented 14 years ago

Reported by fblomqvist, Jun 15, 2009

What steps will reproduce the problem?

  1. Open the Demo
  2. Go to File->Tests->No Canvas Body
  3. Maximize the window

What is the expected output? Window should be maximized to cover the entire workspace.

What do you see instead? Window is resized but the left edge stays at initial position somewhere in the middle of the screen. (and since you can't move a maximized window you can't drag it).

What version of MochaUI are you using? Current SVN version (June 15th)

On what operating system and with what browser? WinXP. FF3, Safari4, Chrome2

Please provide any additional information below. Problem is caused by the lines at #2500 in Window.js (resizeWindow) example: "var top = options.top || oldTop;" The intention is that if options.top is undefined/null the default should be "oldTop". But, if options.top == 0 the OR operation will still evaluate and return oldTop.

Solution: Change to this style instead. "var top = typeof(options.top) != 'undefined' ? options.top : oldTop;" (and similar for the other three places this pattern is used around #2500)

I've been bitten by this gotcha couple of times myself. "||" is just so convenient..

Regards // Fredrik Blomqvist

Comment 1 by fblomqvist, Sep 22, 2009

.. also noticed that the same kind of error is present when setting the initial position of the window. Since the code uses "if (!options.x)" 0 will be interpreted as false. Change to "if (options.x == null)".

// Fredrik

mui-org commented 14 years ago

fixes implement and test