Skip to content

Commit

Permalink
fix: do not animate backdrop for queues (sweetalert2#1900)
Browse files Browse the repository at this point in the history
* fix: do not animate backdrop for queues

* do not remove queue container in removePopupAndResetState()
  • Loading branch information
limonte committed Feb 22, 2020
1 parent f72441c commit 45e1a3a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
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

0 comments on commit 45e1a3a

Please sign in to comment.