-
Notifications
You must be signed in to change notification settings - Fork 127
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
Add visibleFrame to Screen api #43
Conversation
In order to correctly position a Modal you need the (potentially) negative x-coordinate given by the Screen's visibleFrame.
Interesting! Would you be able to give an example when you would need this instead of the origin adjusted |
Sure! I ran into an issue when displaying a modal centered on the current screen. https://github.com/shayne/phonad/blob/master/phoenix.js#L119 |
@shayne Hmm, this shouldn’t be needed. var frame = Screen.mainScreen().visibleFrameInRectangle();
// Centered modal
var modal = new Modal();
modal.message = 'Message';
modal.origin = { x: (frame.width / 2) - (modal.frame().width / 2),
y: (frame.height / 2) - (modal.frame().height / 2) };
modal.show(); Am I missing something? I’m hesitant about merging this to avoid confusion against the origin corrected frames. |
I think leaving the burden of positioning on the JS side is probably a better idea. |
It was my experience that this method centered the modal on the primary On Fri, Nov 20, 2015 at 4:17 AM, Kasper Hirvikoski <notifications@github.com
|
@shayne Only the y-coordinate is adjusted. I’m currently abroad, so I do not have access to my secondary screen, but I successfully use and have used this calculation to centre windows on secondary screens: https://gist.github.com/kasper/b7c2a1596a90246c9ccd#file-phoenix-js-L18 As such, this should work: var frame = Screen.mainScreen().visibleFrameInRectangle();
// Centered modal
var modal = new Modal();
modal.message = 'Message';
modal.origin = { x: frame.x + ((frame.width - modal.frame().width) / 2),
y: frame.y + ((frame.height - modal.frame().height) / 2) };
modal.show(); Still looks easier than your way. :) I’m just hesitant about making this API confusing with multiple available frames and agree with @jasonm23 that the burden to calculate correctly (from the API’s perspective) should be on JavaScript’s side. |
Aha... My secondary screen sits below my primary (MacBook Pro < Thunderbolt On Mon, Nov 23, 2015 at 5:12 AM, Kasper Hirvikoski <notifications@github.com
|
I assumed @jasonm23 was inferring that we keep the frame denormalized and On Mon, Nov 23, 2015 at 6:37 PM, Shayne Sweeney shaynesweeney@me.com
|
@shayne Ah, perhaps. I haven’t changed this behaviour, it has been this way from the beginning. I was puzzled by the actual reason first, but the reason is to make it easier and more straightforward to count the y-position. At least this is how I understand it. Especially as a secondary screen can be positioned in any corner, lower or higher than the main screen — as you just noticed. So I think it’s reasonable. |
I’ll close this for now, but this is duly noted. |
In order to correctly position a Modal you need the (potentially) negative x-coordinate given by the Screen's visibleFrame.