Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not animate backdrop for queues #1900

Merged
merged 2 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/instanceMethods/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function removePopupAndResetState (instance, container, isToast, onAfterClose) {
globalState.keydownHandlerAdded = false
}

if (container.parentNode) {
if (container.parentNode && !document.body.getAttribute('data-swal2-queue-step')) {
container.parentNode.removeChild(container)
}

Expand Down
4 changes: 4 additions & 0 deletions src/scss/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
}
}

&.swal2-no-transition {
transition: none !important;
}

@include not('.swal2-top',
'.swal2-top-start',
'.swal2-top-end',
Expand Down
1 change: 1 addition & 0 deletions src/utils/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const swalClasses = prefix([
'popup',
'modal',
'no-backdrop',
'no-transition',
'toast',
'toast-shown',
'toast-column',
Expand Down
9 changes: 7 additions & 2 deletions src/utils/dom/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const sweetHTML = `
const resetOldContainer = () => {
const oldContainer = getContainer()
if (!oldContainer) {
return
return false
}

oldContainer.parentNode.removeChild(oldContainer)
Expand All @@ -59,6 +59,8 @@ const resetOldContainer = () => {
swalClasses['has-column']
]
)

return true
}

let oldInputVal // IE11 workaround, see #1109 for details
Expand Down Expand Up @@ -120,7 +122,7 @@ const setupRTL = (targetElement) => {
*/
export const init = (params) => {
// Clean up the old popup container if it exists
resetOldContainer()
const oldContainerExisted = resetOldContainer()

/* istanbul ignore if */
if (isNodeEnv()) {
Expand All @@ -130,6 +132,9 @@ export const init = (params) => {

const container = document.createElement('div')
container.className = swalClasses.container
if (oldContainerExisted) {
addClass(container, swalClasses['no-transition'])
}
container.innerHTML = sweetHTML

const targetElement = getTarget(params.target)
Expand Down
1 change: 1 addition & 0 deletions src/utils/openPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const openPopup = (params) => {
if (typeof params.onOpen === 'function') {
setTimeout(() => params.onOpen(popup))
}
dom.removeClass(container, swalClasses['no-transition'])
}

function swalOpenAnimationFinished (event) {
Expand Down