From 8d3ce8d29c9abd89ce47c882e0d7b2ac0f861966 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 24 Feb 2020 11:22:07 -0500 Subject: [PATCH] fix(modal): allow swipe to close animation to be overridden (#20585) fixes #20577 --- core/src/components/modal/modal.tsx | 7 ++- .../src/components/modal/test/spec/index.html | 55 ++++++++++++++++++- core/src/utils/overlays.ts | 5 +- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/core/src/components/modal/modal.tsx b/core/src/components/modal/modal.tsx index c135844c89..b7386cb376 100644 --- a/core/src/components/modal/modal.tsx +++ b/core/src/components/modal/modal.tsx @@ -1,5 +1,6 @@ import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Method, Prop, h } from '@stencil/core'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; import { Animation, AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Gesture, OverlayEventDetail, OverlayInterface } from '../../interface'; import { attachComponent, detachComponent } from '../../utils/framework-delegate'; @@ -150,7 +151,8 @@ export class Modal implements ComponentInterface, OverlayInterface { // All of the elements needed for the swipe gesture // should be in the DOM and referenced by now, except // for the presenting el - const ani = this.animation = iosLeaveAnimation(this.el, this.presentingElement); + const animationBuilder = this.leaveAnimation || config.get('modalLeave', iosLeaveAnimation); + const ani = this.animation = animationBuilder(this.el, this.presentingElement); this.gesture = createSwipeToCloseGesture( this.el, ani, @@ -188,9 +190,8 @@ export class Modal implements ComponentInterface, OverlayInterface { return false; } - const iosAni = (this.animation === undefined || (role === BACKDROP || role === undefined)) ? iosLeaveAnimation : undefined; const enteringAnimation = activeAnimations.get(this) || []; - const dismissed = await dismiss(this, data, role, 'modalLeave', iosAni, mdLeaveAnimation, this.presentingElement); + const dismissed = await dismiss(this, data, role, 'modalLeave', iosLeaveAnimation, mdLeaveAnimation, this.presentingElement); if (dismissed) { await detachComponent(this.delegate, this.usersElement); diff --git a/core/src/components/modal/test/spec/index.html b/core/src/components/modal/test/spec/index.html index 95670f940e..567126c486 100644 --- a/core/src/components/modal/test/spec/index.html +++ b/core/src/components/modal/test/spec/index.html @@ -13,8 +13,9 @@