-
Notifications
You must be signed in to change notification settings - Fork 264
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
Modal fix #89
Modal fix #89
Conversation
Modal should be position absolute, as it is in Foundation 5
@@ -229,7 +229,9 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition']) | |||
body.append(backdropDomEl); | |||
} | |||
|
|||
var angularDomEl = angular.element('<div modal-window></div>'); | |||
var openAt = window.outerWidth > 800 ? $window.scrollY + 100 : $window.scrollY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation, please. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen, this is what vanilla foundation does. It opens the window at 100px offset from the top of your viewport unless its on mobile, then it opens it at 0px offset because the modal is full screen. 800px is the breakpoint at which the modal opens full screen. It's probably better to use a project wide media query module for this but no such module exists yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the current behaviour is that the positioning is fixed. So if a modal is too big, the bottom content can't be scrolled into view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I understand. I was referring to the top offset being set to either scrollY
or scrollY + 100
, depending on the width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm... I've been running that code for a while on a fork. There must have been a reason why I added that. It seems however that its redundant. I'm actually now getting a gap at the top of a small window, with or without that line :|
I removed the 100px offset. On Firefox there is no space at the top now both on desktop and mobile. On Chrome I get the gap at the top on desktop and mobile :/ |
So it appears that the 100px offset is necessary. I'm just not sure why Chrome gives me a gap at the top when the screen is mobile size. |
Yep looks like it. The only thing that bugs me is how we're determining if we're on a small screen. Gonna do some experimentin'. |
Have a look at the mediaQueries service in the top bar module. |
So I did some experimenting with vanilla Foundation, and here's how they solve this: they open the modal window, grab the computed I don't think this is even possible to do in Angular because of the scope lifecycle. |
And yeah, we need a generalized breakpoint detection service to handle this sort of thing for us. I just realized that we redundant detection in both the |
So, whats holding this PR back? I also agree that the redundant detection should be merged, but hopefully that can happen after moving mediaQueries out to be standalone as lots of other parts depends on it. |
When running this on Chrome at a small screen size, the modal opens at a 100px offset. I'm not sure why and haven't taken the time to figure it out. @jbrowning had a look and it looks like vanilla Foundation opens and closes the modal to determine the offset. So this needs a little work. I'm all for merging #99 :) |
We can just rip my offset calculation out of #101 where i get the offset by creating a faux modal It moves one class name to the JS side, but it was required due to animations causing issues in timing the calculation. At the same time, that means it becomes possible to replace the |
@circlingthesun #99 has been merged so would appreciate if you could adapt this to use |
@nervetattoo yeah looks like you were doing basically what VF does in #101 to grab the offset. @circlingthesun this may be the way to go. |
While this is certainly a more elegant way to compute the offset, the problem remains. I've had a closer look the issue. At the time the modal is triggered on a small screen the opening position needs to be window.scrollY and the modal does open at that offset. It appears however that after the modal has opened the view port scrolls up resulting in a gap at the top. Any ideas why this happens? |
Yeah, I don't have issues with it either, except when I run it on the angular foundation demo page. It might be the page length or some other code that is causing this. |
I've debugged it now, it seems its the autofocus code that forces the scroll. |
@nervetattoo, It seems that there was some transclusion iffyness going on. Focusing on a child element instead fixes the issue. Shot for the pointer! @jbrowning I think that sorts it. |
Cool. Is it absolutely guaranteed that there'll be a |
The query resolves to |
Awesome. Thanks for all your work on this gentlemen. 🍻 |
Thank you for the fix ! 😄 |
Makes off screen modals accessible by opening a non fixed window at the scroll offset position on screen. Fixes #87