Web: Common: PageLayout: Fixed Article pin on mobile

This commit is contained in:
Ilya Oleshko 2020-02-11 11:11:34 +03:00
parent 61fceef6db
commit 0e8adf3066

View File

@ -33,9 +33,13 @@ class PageLayoutComponent extends React.PureComponent {
}
orientationChangeHandler = () => {
const isOrientationVertical = !(screen.orientation.angle % 180);
const articleElement = document.getElementsByTagName('article')[0];
if (!articleElement) return;
const isOrientationVertical = !(screen.orientation ? screen.orientation.angle % 180 : window.matchMedia("(orientation: portrait)"));
const isValueExist = !!localStorage.getItem(ARTICLE_PINNED_KEY);
const articleWidth = document.getElementsByTagName('article')[0].offsetWidth;
const articleWidth = articleElement.offsetWidth;
const isArticleWide = articleWidth > screen.availWidth - articleWidth;
if (isOrientationVertical && isArticleWide && isValueExist) {