mirror of
https://github.com/flarum/core.git
synced 2025-08-11 02:44:04 +02:00
More mobile UX improvements
- Reposition the composer when shown - Make preview button scroll the parent frame down - Fix iframe infinite height loop
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { override, extend } from 'flarum/extend';
|
||||
import app from 'flarum/app';
|
||||
import Composer from 'flarum/components/Composer';
|
||||
import PostStream from 'flarum/components/PostStream';
|
||||
import ModalManager from 'flarum/components/ModalManager';
|
||||
import AlertManager from 'flarum/components/AlertManager';
|
||||
import PostMeta from 'flarum/components/PostMeta';
|
||||
@@ -37,10 +38,13 @@ app.initializers.replace('boot', () => {
|
||||
|
||||
app.pageInfo = m.prop();
|
||||
|
||||
extend(ModalManager.prototype, 'show', function() {
|
||||
const reposition = function() {
|
||||
const info = app.pageInfo();
|
||||
this.$().css('top', Math.max(0, info.scrollTop - info.offsetTop));
|
||||
});
|
||||
};
|
||||
|
||||
extend(ModalManager.prototype, 'show', reposition);
|
||||
extend(Composer.prototype, 'show', reposition);
|
||||
|
||||
window.iFrameResizer = {
|
||||
readyCallback: function() {
|
||||
@@ -48,6 +52,13 @@ app.initializers.replace('boot', () => {
|
||||
}
|
||||
};
|
||||
|
||||
extend(PostStream.prototype, 'goToNumber', function(promise, number) {
|
||||
if (number === 'reply' && 'parentIFrame' in window && app.composer.$().css('position') === 'absolute') {
|
||||
const itemTop = this.$('.PostStream-item:last').offset().top;
|
||||
window.parentIFrame.scrollToOffset(0, itemTop);
|
||||
}
|
||||
});
|
||||
|
||||
app.pane = new Pane(document.getElementById('app'));
|
||||
app.drawer = new Drawer();
|
||||
app.composer = m.mount(document.getElementById('composer'), Composer.component());
|
||||
|
Reference in New Issue
Block a user