client/posts: fix viewport height calculation on iOS

This commit is contained in:
Michael Serajnik 2018-04-05 19:42:27 +02:00
parent 043fdf7966
commit 721916dadc

View file

@ -1,5 +1,6 @@
'use strict'; 'use strict';
const iosCorrectedInnerHeight = require('ios-inner-height');
const router = require('../router.js'); const router = require('../router.js');
const views = require('../util/views.js'); const views = require('../util/views.js');
const uri = require('../util/uri.js'); const uri = require('../util/uri.js');
@ -26,23 +27,20 @@ class PostMainView {
views.replaceContent(this._hostNode, sourceNode); views.replaceContent(this._hostNode, sourceNode);
views.syncScrollPosition(); views.syncScrollPosition();
const postViewNode = document.body.querySelector('.content-wrapper');
const topNavigationNode = const topNavigationNode =
document.body.querySelector('#top-navigation'); document.body.querySelector('#top-navigation');
const margin = (
postViewNode.getBoundingClientRect().top -
topNavigationNode.getBoundingClientRect().height);
this._postContentControl = new PostContentControl( this._postContentControl = new PostContentControl(
postContainerNode, postContainerNode,
ctx.post, ctx.post,
() => { () => {
const margin = sidebarNode.getBoundingClientRect().left;
return [ return [
window.innerWidth - window.innerWidth -
postContainerNode.getBoundingClientRect().left - postContainerNode.getBoundingClientRect().left -
margin, margin,
window.innerHeight - iosCorrectedInnerHeight() -
topNavigationNode.getBoundingClientRect().height - topNavigationNode.getBoundingClientRect().height -
margin * 2, margin * 2,
]; ];