Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting initial window position no longer works #5

Closed
abulka opened this issue Mar 1, 2021 · 1 comment
Closed

Setting initial window position no longer works #5

abulka opened this issue Mar 1, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@abulka
Copy link

abulka commented Mar 1, 2021

A couple of bugs re window positioning seem to have been introduced recently.

Centering a window by omitting position option no longer works

Setting the window position to be the center of the screen, by omitting the position option no longer works after 19b62de

if(typeof options.position !== "object"){
  options.position = {
    x: 0,
    y: 0
  };
}

The above code breaks the initial nice, centering of a window, when you don't specify an initial position. All such windows end up at 0,0 rather than in the center of the screen. The useful windowjs code

options.position = { x: (parent.offsetWidth / 2 - container.offsetWidth / 2), y: (parent.offsetHeight / 2 - container.offsetHeight / 2) };

is thus wasted.

Setting the initial window position is broken

Setting the initial window position e.g.

new Window("Title", {
    state: WindowState.NORMAL,
    size: {
        width: 500,
        height: 250
    },
    position : {x: 20, y: 20},
   ...
})

is broken after f417b38 and no longer works - every window appears at 0,0 due to the introduction of this code:

if(typeof options.position.x !== "object"){
  options.position.x = 0;
}
if(typeof options.position.y !== "object"){
  options.position.y = 0;
}

The above code expects position to be an object (fair enough) and also wants the x and y values to be objects too? - which isn't right. x and y are actually numbers e.g. position : {x: 20, y: 20}. Perhaps the code should be checking for type "number", though if the user hasn't specified position as an option this code will break, so the two matters raised in this GitHub issue are related.

The windowjs library seems to work better without these two changes!

@m-thalmann
Copy link
Owner

You are absolutely right. I will fix this asap.

@m-thalmann m-thalmann added the bug Something isn't working label Mar 1, 2021
@m-thalmann m-thalmann self-assigned this Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants