Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Fixes #572 - Body styles getting overridden (#660)
Browse files Browse the repository at this point in the history
* Fixes #572 - Body styles getting overriden

* Fix build
  • Loading branch information
murtaza98 authored Nov 19, 2021
1 parent b65502e commit 66c7a13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ body {

height: 100%;
}

.rc-livechat-mobile-full-screen {
overflow: hidden;

width: 100%;
height: 100%;
}
11 changes: 4 additions & 7 deletions src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const WIDGET_OPEN_HEIGHT = 525;
const WIDGET_MINIMIZED_WIDTH = 54;
const WIDGET_MINIMIZED_HEIGHT = 54;
const WIDGET_MARGIN = 16;
const FULLSCREEN_DOCUMENT_CONFIG = 'overflow: hidden; height: 100%; width: 100%;';


window.RocketChat = window.RocketChat || { _: [] };
Expand All @@ -21,7 +20,6 @@ let iframe;
let hookQueue = [];
let ready = false;
let smallScreen = false;
let bodyStyle;
let scrollPosition;
let widget_height;

Expand Down Expand Up @@ -74,10 +72,9 @@ function callHook(action, params) {
const updateWidgetStyle = (isOpened) => {
if (smallScreen && isOpened) {
scrollPosition = document.documentElement.scrollTop;
bodyStyle = document.body.style.cssText;
document.body.style.cssText += FULLSCREEN_DOCUMENT_CONFIG;
document.body.classList.add('rc-livechat-mobile-full-screen');
} else {
document.body.style.cssText = bodyStyle;
document.body.classList.remove('rc-livechat-mobile-full-screen');
if (smallScreen) {
document.documentElement.scrollTop = scrollPosition;
}
Expand Down Expand Up @@ -235,11 +232,11 @@ const api = {
},

resetDocumentStyle() {
document.body.style.cssText = bodyStyle;
document.body.classList.remove('rc-livechat-mobile-full-screen');
},

setFullScreenDocumentMobile() {
document.body.style.cssText += smallScreen && FULLSCREEN_DOCUMENT_CONFIG;
smallScreen && document.body.classList.add('rc-livechat-mobile-full-screen');
},
};

Expand Down

0 comments on commit 66c7a13

Please sign in to comment.