mirror of
https://github.com/flarum/framework.git
synced 2025-02-07 16:33:00 +08:00
Use absolute positioning for the Composer on Safari (#2660)
This commit is contained in:
parent
eec39ec426
commit
970db778cd
|
@ -16,6 +16,7 @@ import NotificationListState from './states/NotificationListState';
|
||||||
import GlobalSearchState from './states/GlobalSearchState';
|
import GlobalSearchState from './states/GlobalSearchState';
|
||||||
import DiscussionListState from './states/DiscussionListState';
|
import DiscussionListState from './states/DiscussionListState';
|
||||||
import ComposerState from './states/ComposerState';
|
import ComposerState from './states/ComposerState';
|
||||||
|
import isSafariMobile from './utils/isSafariMobile';
|
||||||
|
|
||||||
export default class ForumApplication extends Application {
|
export default class ForumApplication extends Application {
|
||||||
/**
|
/**
|
||||||
|
@ -138,6 +139,12 @@ export default class ForumApplication extends Application {
|
||||||
m.redraw();
|
m.redraw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isSafariMobile()) {
|
||||||
|
$(() => {
|
||||||
|
$('.App').addClass('mobile-safari');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -265,7 +265,10 @@ export default class Composer extends Component {
|
||||||
this.animateHeightChange().then(() => this.focus());
|
this.animateHeightChange().then(() => this.focus());
|
||||||
|
|
||||||
if (app.screen() === 'phone') {
|
if (app.screen() === 'phone') {
|
||||||
this.$().css('top', 0);
|
// On safari fixed position doesn't properly work on mobile,
|
||||||
|
// So we use absolute and set the top value.
|
||||||
|
// https://github.com/flarum/core/issues/2652
|
||||||
|
this.$().css('top', $('.App').is('.mobile-safari') ? $(window).scrollTop() : 0);
|
||||||
this.showBackdrop();
|
this.showBackdrop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
framework/core/js/src/forum/utils/isSafariMobile.ts
Normal file
13
framework/core/js/src/forum/utils/isSafariMobile.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* @see https://stackoverflow.com/a/31732310
|
||||||
|
*/
|
||||||
|
export default function isSafariMobile(): boolean {
|
||||||
|
return (
|
||||||
|
'ontouchstart' in window &&
|
||||||
|
navigator.vendor &&
|
||||||
|
navigator.vendor.includes('Apple') &&
|
||||||
|
navigator.userAgent &&
|
||||||
|
!navigator.userAgent.includes('CriOS') &&
|
||||||
|
!navigator.userAgent.includes('FxiOS')
|
||||||
|
);
|
||||||
|
}
|
|
@ -120,6 +120,12 @@
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
padding-top: @header-height-phone;
|
padding-top: @header-height-phone;
|
||||||
|
|
||||||
|
// Fixes a bug where fixed position doesn't properly work in Safari mobile
|
||||||
|
// https://github.com/flarum/core/issues/2652
|
||||||
|
.mobile-safari & {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
content: " ";
|
content: " ";
|
||||||
.header-background();
|
.header-background();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user