fix: Smoothens out opening animation for widget (#2789)
This commit is contained in:
parent
e09941db1c
commit
70d41ffcdd
4 changed files with 56 additions and 23 deletions
|
@ -97,6 +97,15 @@ export const IFrameHelper = {
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
setFrameHeightToFitContent: (extraHeight, isFixedHeight) => {
|
||||
const iframe = IFrameHelper.getAppFrame();
|
||||
const updatedIframeHeight = isFixedHeight ? `${extraHeight}px` : '100%';
|
||||
|
||||
if (iframe)
|
||||
iframe.setAttribute('style', `height: ${updatedIframeHeight} !important`);
|
||||
},
|
||||
|
||||
events: {
|
||||
loaded: message => {
|
||||
Cookies.set('cw_conversation', message.config.authToken, {
|
||||
|
@ -169,6 +178,13 @@ export const IFrameHelper = {
|
|||
}
|
||||
},
|
||||
|
||||
updateIframeHeight: message => {
|
||||
const { extraHeight = 0, isFixedHeight } = message;
|
||||
if (!extraHeight) return;
|
||||
|
||||
IFrameHelper.setFrameHeightToFitContent(extraHeight, isFixedHeight);
|
||||
},
|
||||
|
||||
resetUnreadMode: () => {
|
||||
IFrameHelper.sendMessage('unset-unread-view');
|
||||
IFrameHelper.events.removeUnreadClass();
|
||||
|
@ -178,22 +194,6 @@ export const IFrameHelper = {
|
|||
const holderEl = document.querySelector('.woot-widget-holder');
|
||||
removeClass(holderEl, 'has-unread-view');
|
||||
},
|
||||
|
||||
updateIframeHeight: message => {
|
||||
setTimeout(() => {
|
||||
const iframe = IFrameHelper.getAppFrame();
|
||||
const scrollableMessageHeight =
|
||||
iframe.contentWindow.document.querySelector('.unread-messages')
|
||||
.scrollHeight + 40;
|
||||
const updatedIframeHeight = message.isFixedHeight
|
||||
? `${scrollableMessageHeight}px`
|
||||
: '100%';
|
||||
iframe.setAttribute(
|
||||
'style',
|
||||
`height: ${updatedIframeHeight} !important`
|
||||
);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
pushEvent: eventName => {
|
||||
IFrameHelper.sendMessage('push-event', { eventName });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue