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 window position #17

Closed
909oce opened this issue Mar 20, 2024 · 5 comments
Closed

setting window position #17

909oce opened this issue Mar 20, 2024 · 5 comments
Labels
question Further information is requested

Comments

@909oce
Copy link

909oce commented Mar 20, 2024

hi, im having some trouble and hoping someone more knowledge might be able to help.

i know that we have center(); to set a window to be centered, however im trying to set a window to be next to another one on creation.

using css left: 500 during creation doesnt work as that doesnt take the browser size into account and causes varying results.

is there some way to do this that im not seeing? thanks

@1j01 1j01 added the question Further information is requested label Mar 30, 2024
@1j01
Copy link
Owner

1j01 commented Mar 30, 2024

I'd be happy to help, but I need more details.

  • What does your code look like?
  • What exactly are you trying to achieve overall?
  • How do you want to take the browser size into account, and what is happening instead?

Screenshots/mockups might help to explain.

@909oce
Copy link
Author

909oce commented Apr 1, 2024

Could you send me a message on Discord? I think it would be easier to screenshare my project and explain it rather than write it all out here.

Discord: 909oce

@JoshDoesStuff
Copy link

Hello, how did you get window positioning to work? Like you stated, using position: absolute and left: 500px in the style tags do not cause the windows to spawn in that position, still spawning in the center.

@1j01
Copy link
Owner

1j01 commented May 17, 2024

@JoshDoesStuff There's no API specifically for positioning windows currently.

The way to do it right now is to use jQuery's .css() method, or otherwise setting inline styles.
For example:

$win.css({ left: 500, top: 200 });

Styles defined in a stylesheet will not apply (without !important) as inline styles will override them, and the windows have inline styles by default for left and top.

This topic definitely deserves documentation, regardless of whether there's an API for it or not, and a helper method might be nice.

Also, note that the $Window API is returning a jQuery object extended with additional methods and properties. This was a really bad decision I made 10 years ago when I was a kid, and didn't know about the benefits of composition over inheritance (or that jQuery would become less useful over time).
I have already converted the $MenuBar class into a MenuBar class, removing the dependency on jQuery, and I plan to do the same for $Window, although I won't be able to name it Window, as that's a built-in DOM API. I'll probably add a prefix.

@1j01
Copy link
Owner

1j01 commented May 29, 2024

I added a section to the docs about positioning windows.

@1j01 1j01 closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants