Skip to content

Commit

Permalink
fix(DIST-713): Removed extra timing (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Prilutskiy authored Feb 4, 2021
1 parent 2c90dd7 commit 04d64ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/core/views/components/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Iframe extends Component {
}

async handleLoad() {
this.props.onLoad(this.iframeRef)
await Promise.resolve(this.props.onLoad(this.iframeRef))
await this.triggerIframeRedraw()
}

Expand All @@ -42,7 +42,7 @@ class Iframe extends Component {
setTimeout(() => {
this.iframeRef.style.display = 'block'
resolve()
}, 500)
})
} catch (err) {
reject(err)
}
Expand Down
27 changes: 15 additions & 12 deletions src/core/views/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const popupWrapper = styled(BaseWrapper)`
${({ size }) =>
size &&
`
height: calc(${size}% - 80px);
width: calc(${size}% - 80px);
height: calc(${size}% - 80px);
width: calc(${size}% - 80px);
`}
transition: all 300ms ease-out;
`
Expand Down Expand Up @@ -258,17 +258,20 @@ class Popup extends Component {
}

handleIframeLoad(iframeRef) {
this.setState({ iframeLoaded: true }, () => {
setTimeout(() => {
if (this.state.isLoading) {
this.updateIcon(<IconCloseImage alt="close-typeform" data-qa="popup-close-button" src={closeImg} />)
this.handleSidePanelOpen()
this.setState({ frameAnimate: true, isLoading: false })
if (iframeRef && iframeRef.contentWindow) {
iframeRef.contentWindow.focus()
return new Promise((resolve) => {
this.setState({ iframeLoaded: true }, () => {
setTimeout(() => {
if (this.state.isLoading) {
this.updateIcon(<IconCloseImage alt="close-typeform" data-qa="popup-close-button" src={closeImg} />)
this.handleSidePanelOpen()
this.setState({ frameAnimate: true, isLoading: false })
if (iframeRef && iframeRef.contentWindow) {
iframeRef.contentWindow.focus()
}
}
}
}, 500)
resolve()
}, 500)
})
})
}

Expand Down

0 comments on commit 04d64ab

Please sign in to comment.