Make animation optional for Modal.setVisible (#903)

This commit is contained in:
toasted-nutbread 2020-10-10 10:47:02 -04:00 committed by GitHub
parent 591253d783
commit 6799b87cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ class Modal extends EventDispatcher {
}
}
setVisible(value) {
setVisible(value, animate=true) {
value = !!value;
if (this._useJqueryModal()) {
this._getWrappedNode().modal(value ? 'show' : 'hide');
@ -55,15 +55,16 @@ class Modal extends EventDispatcher {
}
if (value) {
classList.add(this._openingClassName);
if (animate) { classList.add(this._openingClassName); }
classList.remove(this._closingClassName);
getComputedStyle(this._node).getPropertyValue('display'); // Force update of CSS display property, allowing animation
classList.add(this._visibleClassName);
classList.remove(this._closingClassName);
classList.remove(this._openingClassName);
if (animate) { classList.remove(this._openingClassName); }
this._node.focus();
} else {
classList.add(this._closingClassName);
if (animate) { classList.add(this._closingClassName); }
classList.remove(this._visibleClassName);
if (animate) {
this._closeTimer = setTimeout(() => {
this._closeTimer = null;
classList.remove(this._closingClassName);
@ -71,6 +72,7 @@ class Modal extends EventDispatcher {
}
}
}
}
on(eventName, callback) {
if (eventName === 'visibilityChanged') {