1 thought on “Windows.setPosition(“center”) still bug?

  1. The root cause is that resizeTo is an async API and setPosition is implemented based on current bounds of app window. After resizeTo is called, the bounds is not updated immediately until the window is actually resized. So that setPosition is still using the old size and turned out to get a wrong position.

    If you want your window always pinning to the center of the screen, hook up resize and move events of win and call setPosition('center') in the event handler.

    If you want to move it immediately to center just once, you can manually calculate and set window’s x and y coordinations after calling resizeTo. See calculation in NW.js source code.

Comments are closed.