Responsive fixes

- Make composer absolutely positioned on mobile to work around iOS 8/9
bug
- Make search results dropdown appear on mobile

closes flarum/core#137
This commit is contained in:
Toby Zerner 2015-08-04 11:27:51 +09:30
parent 856ebe9d42
commit 7154558239
4 changed files with 38 additions and 3 deletions

View File

@ -260,6 +260,14 @@ class Composer extends Component {
$composer.show() $composer.show()
.css({height: oldHeight}) .css({height: oldHeight})
.animate({bottom: 0, height: newHeight}, 'fast', this.component.focus.bind(this.component)); .animate({bottom: 0, height: newHeight}, 'fast', this.component.focus.bind(this.component));
if ($composer.css('position') === 'absolute') {
$composer.css('top', $(window).scrollTop());
this.$backdrop = $('<div/>')
.addClass('composer-backdrop')
.appendTo('body');
}
} else { } else {
this.component.focus(); this.component.focus();
} }
@ -268,20 +276,24 @@ class Composer extends Component {
case Composer.PositionEnum.MINIMIZED: case Composer.PositionEnum.MINIMIZED:
// If the composer has been minimized, we will animate it shrinking down // If the composer has been minimized, we will animate it shrinking down
// to its new smaller size. // to its new smaller size.
$composer.css({height: oldHeight}) $composer.css({top: 'auto', height: oldHeight})
.animate({height: newHeight}, 'fast'); .animate({height: newHeight}, 'fast');
if (this.$backdrop) this.$backdrop.remove();
break; break;
case Composer.PositionEnum.HIDDEN: case Composer.PositionEnum.HIDDEN:
// If the composer has been hidden, then we will animate it sliding down // If the composer has been hidden, then we will animate it sliding down
// beyond the edge of the viewport. Once the animation is complete, we // beyond the edge of the viewport. Once the animation is complete, we
// un-draw the composer's component. // un-draw the composer's component.
$composer.css({height: oldHeight}) $composer.css({top: 'auto', height: oldHeight})
.animate({bottom: -newHeight}, 'fast', () => { .animate({bottom: -newHeight}, 'fast', () => {
$composer.hide(); $composer.hide();
this.clear(); this.clear();
m.redraw(); m.redraw();
}); });
if (this.$backdrop) this.$backdrop.remove();
break; break;
case Composer.PositionEnum.FULLSCREEN: case Composer.PositionEnum.FULLSCREEN:

View File

@ -75,7 +75,7 @@ export default class Search extends Component {
} }
return ( return (
<div className={'Search Dropdown ' + classList({ <div className={'Search ' + classList({
open: this.value() && this.hasFocus, open: this.value() && this.hasFocus,
active: !!currentSearch, active: !!currentSearch,
loading: !!this.loadingSources loading: !!this.loadingSources

View File

@ -113,6 +113,7 @@
background: @body-bg; background: @body-bg;
&:not(.minimized) { &:not(.minimized) {
position: absolute;
top: 0; top: 0;
height: 100vh !important; height: 100vh !important;
padding-top: @header-height-phone; padding-top: @header-height-phone;
@ -120,6 +121,7 @@
&:before { &:before {
content: " "; content: " ";
.header-background(); .header-background();
position: absolute;
opacity: 0; opacity: 0;
.visible& { .visible& {
@ -128,14 +130,28 @@
} }
& .Composer-controls { & .Composer-controls {
position: static;
z-index: @zindex-header + 1; z-index: @zindex-header + 1;
li:not(.App-backControl) { li:not(.App-backControl) {
display: none; display: none;
} }
.App-backControl {
position: absolute !important;
}
} }
} }
} }
.composer-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: @zindex-composer - 1;
background-color: @overlay-bg;
opacity: 0.9;
}
.ComposerBody-content { .ComposerBody-content {
.minimized & { .minimized & {
margin-right: 50px; margin-right: 50px;

View File

@ -1,3 +1,6 @@
.Search {
position: relative;
}
@media @tablet-up { @media @tablet-up {
.Search { .Search {
input:focus, &.active input, .Search-results { input:focus, &.active input, .Search-results {
@ -11,6 +14,10 @@
left: auto; left: auto;
right: 0; right: 0;
@media @phone {
left: 0;
}
> li > a { > li > a {
white-space: normal; white-space: normal;
} }