From e523ee0513b74321c3dea21b30a80726804ddded Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Fri, 9 Nov 2018 16:55:52 -0500 Subject: [PATCH 1/8] fix(toast): update naming to match other animations --- core/src/components/toast/animations/ios.enter.ts | 9 +++++---- core/src/components/toast/animations/ios.leave.ts | 4 ++-- core/src/components/toast/animations/md.enter.ts | 8 ++++---- core/src/components/toast/animations/md.leave.ts | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/src/components/toast/animations/ios.enter.ts b/core/src/components/toast/animations/ios.enter.ts index 512fdc6f9ec..0aa72501c94 100644 --- a/core/src/components/toast/animations/ios.enter.ts +++ b/core/src/components/toast/animations/ios.enter.ts @@ -7,8 +7,9 @@ export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, po const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); - const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement; - wrapperAnimation.addElement(wrapperEle); + const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + + wrapperAnimation.addElement(wrapperEl); const bottom = `calc(-10px - var(--ion-safe-area-bottom, 0px))`; const top = `calc(10px + var(--ion-safe-area-top, 0px))`; @@ -19,9 +20,9 @@ export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, po break; case 'middle': const topPosition = Math.floor( - baseEl.clientHeight / 2 - wrapperEle.clientHeight / 2 + baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2 ); - wrapperEle.style.top = `${topPosition}px`; + wrapperEl.style.top = `${topPosition}px`; wrapperAnimation.fromTo('opacity', 0.01, 1); break; default: diff --git a/core/src/components/toast/animations/ios.leave.ts b/core/src/components/toast/animations/ios.leave.ts index 2abb50b25dc..79f853df376 100644 --- a/core/src/components/toast/animations/ios.leave.ts +++ b/core/src/components/toast/animations/ios.leave.ts @@ -7,8 +7,8 @@ export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, po const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); - const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement; - wrapperAnimation.addElement(wrapperEle); + const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); const bottom = `calc(-10px - var(--ion-safe-area-bottom, 0px))`; const top = `calc(10px + var(--ion-safe-area-top, 0px))`; diff --git a/core/src/components/toast/animations/md.enter.ts b/core/src/components/toast/animations/md.enter.ts index 176c7e9900d..9fa67cabe2a 100644 --- a/core/src/components/toast/animations/md.enter.ts +++ b/core/src/components/toast/animations/md.enter.ts @@ -7,8 +7,8 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); - const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement; - wrapperAnimation.addElement(wrapperEle); + const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); switch (position) { case 'top': @@ -16,9 +16,9 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos break; case 'middle': const topPosition = Math.floor( - baseEl.clientHeight / 2 - wrapperEle.clientHeight / 2 + baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2 ); - wrapperEle.style.top = `${topPosition}px`; + wrapperEl.style.top = `${topPosition}px`; wrapperAnimation.fromTo('opacity', 0.01, 1); break; default: diff --git a/core/src/components/toast/animations/md.leave.ts b/core/src/components/toast/animations/md.leave.ts index 321f5187483..0b2db25ad2e 100644 --- a/core/src/components/toast/animations/md.leave.ts +++ b/core/src/components/toast/animations/md.leave.ts @@ -7,8 +7,8 @@ export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, pos const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); - const wrapperEle = baseEl.querySelector('.toast-wrapper') as HTMLElement; - wrapperAnimation.addElement(wrapperEle); + const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); switch (position) { case 'top': From 5adb1e4258ce685e2fd79b5ab546de6c859d668c Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 13 Nov 2018 11:40:42 -0500 Subject: [PATCH 2/8] fix(toast): update animation to use correct safe area --- core/src/components/toast/animations/ios.leave.ts | 1 + core/src/components/toast/animations/md.enter.ts | 8 ++++++-- core/src/components/toast/animations/md.leave.ts | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/components/toast/animations/ios.leave.ts b/core/src/components/toast/animations/ios.leave.ts index 79f853df376..08f02f19c13 100644 --- a/core/src/components/toast/animations/ios.leave.ts +++ b/core/src/components/toast/animations/ios.leave.ts @@ -8,6 +8,7 @@ export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, po const wrapperAnimation = new AnimationC(); const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); const bottom = `calc(-10px - var(--ion-safe-area-bottom, 0px))`; diff --git a/core/src/components/toast/animations/md.enter.ts b/core/src/components/toast/animations/md.enter.ts index 9fa67cabe2a..208366fb2b3 100644 --- a/core/src/components/toast/animations/md.enter.ts +++ b/core/src/components/toast/animations/md.enter.ts @@ -8,11 +8,15 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos const wrapperAnimation = new AnimationC(); const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); + const bottom = `calc(-8px - var(--ion-safe-area-bottom, 0px))`; + const top = `calc(8px + var(--ion-safe-area-top, 0px))`; + switch (position) { case 'top': - wrapperAnimation.fromTo('translateY', '-100%', '0%'); + wrapperAnimation.fromTo('translateY', '-100%', top); break; case 'middle': const topPosition = Math.floor( @@ -22,7 +26,7 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos wrapperAnimation.fromTo('opacity', 0.01, 1); break; default: - wrapperAnimation.fromTo('translateY', '100%', '0%'); + wrapperAnimation.fromTo('translateY', '100%', bottom); break; } return Promise.resolve(baseAnimation diff --git a/core/src/components/toast/animations/md.leave.ts b/core/src/components/toast/animations/md.leave.ts index 0b2db25ad2e..75224c64d19 100644 --- a/core/src/components/toast/animations/md.leave.ts +++ b/core/src/components/toast/animations/md.leave.ts @@ -8,17 +8,21 @@ export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, pos const wrapperAnimation = new AnimationC(); const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; + wrapperAnimation.addElement(wrapperEl); + const bottom = `calc(-8px - var(--ion-safe-area-bottom, 0px))`; + const top = `calc(8px + var(--ion-safe-area-top, 0px))`; + switch (position) { case 'top': - wrapperAnimation.fromTo('translateY', '0px', '-100%'); + wrapperAnimation.fromTo('translateY', top, '-100%'); break; case 'middle': wrapperAnimation.fromTo('opacity', 0.99, 0); break; default: - wrapperAnimation.fromTo('translateY', `0px`, '100%'); + wrapperAnimation.fromTo('translateY', bottom, '100%'); break; } return Promise.resolve(baseAnimation From 04337502183d74e361e877616cef7b32e4cc83a6 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 13 Nov 2018 17:35:31 -0500 Subject: [PATCH 3/8] fix(toast): fix the position middle and animations for toast fixes #16271 --- .../animation-controller/animation-interface.tsx | 2 +- core/src/components/toast/animations/ios.enter.ts | 8 +++++--- core/src/components/toast/animations/ios.leave.ts | 6 ++++-- core/src/components/toast/animations/md.enter.ts | 8 +++++--- core/src/components/toast/animations/md.leave.ts | 6 ++++-- core/src/utils/overlays.ts | 2 +- core/src/utils/transition.ts | 2 +- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/core/src/components/animation-controller/animation-interface.tsx b/core/src/components/animation-controller/animation-interface.tsx index dbf1ac9c97a..eb658cf80b8 100644 --- a/core/src/components/animation-controller/animation-interface.tsx +++ b/core/src/components/animation-controller/animation-interface.tsx @@ -41,7 +41,7 @@ export interface Animation { hasCompleted: boolean; } -export type AnimationBuilder = (Animation: Animation, baseEl: HTMLElement, opts?: any) => Promise; +export type AnimationBuilder = (Animation: Animation, baseEl: any, opts?: any) => Promise; export interface PlayOptions { duration?: number; diff --git a/core/src/components/toast/animations/ios.enter.ts b/core/src/components/toast/animations/ios.enter.ts index 0aa72501c94..f738c219674 100644 --- a/core/src/components/toast/animations/ios.enter.ts +++ b/core/src/components/toast/animations/ios.enter.ts @@ -3,10 +3,12 @@ import { Animation } from '../../../interface'; /** * iOS Toast Enter Animation */ -export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, position: string): Promise { +export function iosEnterAnimation(AnimationC: Animation, baseEl: ShadowRoot, position: string): Promise { const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); + + const hostEl = baseEl.host || baseEl; const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; wrapperAnimation.addElement(wrapperEl); @@ -20,7 +22,7 @@ export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, po break; case 'middle': const topPosition = Math.floor( - baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2 + hostEl.clientHeight / 2 - wrapperEl.clientHeight / 2 ); wrapperEl.style.top = `${topPosition}px`; wrapperAnimation.fromTo('opacity', 0.01, 1); @@ -30,7 +32,7 @@ export function iosEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, po break; } return Promise.resolve(baseAnimation - .addElement(baseEl) + .addElement(hostEl) .easing('cubic-bezier(.155,1.105,.295,1.12)') .duration(400) .add(wrapperAnimation)); diff --git a/core/src/components/toast/animations/ios.leave.ts b/core/src/components/toast/animations/ios.leave.ts index 08f02f19c13..9ee06c70ab4 100644 --- a/core/src/components/toast/animations/ios.leave.ts +++ b/core/src/components/toast/animations/ios.leave.ts @@ -3,10 +3,12 @@ import { Animation } from '../../../interface'; /** * iOS Toast Leave Animation */ -export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, position: string): Promise { +export function iosLeaveAnimation(AnimationC: Animation, baseEl: ShadowRoot, position: string): Promise { const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); + + const hostEl = baseEl.host || baseEl; const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; wrapperAnimation.addElement(wrapperEl); @@ -26,7 +28,7 @@ export function iosLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, po break; } return Promise.resolve(baseAnimation - .addElement(baseEl) + .addElement(hostEl) .easing('cubic-bezier(.36,.66,.04,1)') .duration(300) .add(wrapperAnimation)); diff --git a/core/src/components/toast/animations/md.enter.ts b/core/src/components/toast/animations/md.enter.ts index 208366fb2b3..998f4034b9a 100644 --- a/core/src/components/toast/animations/md.enter.ts +++ b/core/src/components/toast/animations/md.enter.ts @@ -3,10 +3,12 @@ import { Animation } from '../../../interface'; /** * MD Toast Enter Animation */ -export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, position: string): Promise { +export function mdEnterAnimation(AnimationC: Animation, baseEl: ShadowRoot, position: string): Promise { const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); + + const hostEl = baseEl.host || baseEl; const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; wrapperAnimation.addElement(wrapperEl); @@ -20,7 +22,7 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos break; case 'middle': const topPosition = Math.floor( - baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2 + hostEl.clientHeight / 2 - wrapperEl.clientHeight / 2 ); wrapperEl.style.top = `${topPosition}px`; wrapperAnimation.fromTo('opacity', 0.01, 1); @@ -30,7 +32,7 @@ export function mdEnterAnimation(AnimationC: Animation, baseEl: HTMLElement, pos break; } return Promise.resolve(baseAnimation - .addElement(baseEl) + .addElement(hostEl) .easing('cubic-bezier(.36,.66,.04,1)') .duration(400) .add(wrapperAnimation)); diff --git a/core/src/components/toast/animations/md.leave.ts b/core/src/components/toast/animations/md.leave.ts index 75224c64d19..6b9468a94e3 100644 --- a/core/src/components/toast/animations/md.leave.ts +++ b/core/src/components/toast/animations/md.leave.ts @@ -3,10 +3,12 @@ import { Animation } from '../../../interface'; /** * md Toast Leave Animation */ -export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, position: string): Promise { +export function mdLeaveAnimation(AnimationC: Animation, baseEl: ShadowRoot, position: string): Promise { const baseAnimation = new AnimationC(); const wrapperAnimation = new AnimationC(); + + const hostEl = baseEl.host || baseEl; const wrapperEl = baseEl.querySelector('.toast-wrapper') as HTMLElement; wrapperAnimation.addElement(wrapperEl); @@ -26,7 +28,7 @@ export function mdLeaveAnimation(AnimationC: Animation, baseEl: HTMLElement, pos break; } return Promise.resolve(baseAnimation - .addElement(baseEl) + .addElement(hostEl) .easing('cubic-bezier(.36,.66,.04,1)') .duration(300) .add(wrapperAnimation)); diff --git a/core/src/utils/overlays.ts b/core/src/utils/overlays.ts index 27ca1cdb2c0..b1920e60adb 100644 --- a/core/src/utils/overlays.ts +++ b/core/src/utils/overlays.ts @@ -132,7 +132,7 @@ function getAppRoot(doc: Document) { async function overlayAnimation( overlay: OverlayInterface, animationBuilder: AnimationBuilder, - baseEl: HTMLElement, + baseEl: any, opts: any ): Promise { if (overlay.animation) { diff --git a/core/src/utils/transition.ts b/core/src/utils/transition.ts index f85d9605d54..01938affcc8 100644 --- a/core/src/utils/transition.ts +++ b/core/src/utils/transition.ts @@ -216,7 +216,7 @@ export interface TransitionOptions extends NavOptions { queue: QueueApi; progressCallback?: ((ani: Animation) => void); window: Window; - baseEl: HTMLElement; + baseEl: any; enteringEl: HTMLElement; leavingEl: HTMLElement | undefined; } From b3225a9c06f42576f049554cd5dd676a3f671ff7 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Tue, 13 Nov 2018 17:35:52 -0500 Subject: [PATCH 4/8] test(core): update tests to latest --- .../components/toast/test/basic/index.html | 2 +- core/src/themes/test/css-variables/index.html | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/core/src/components/toast/test/basic/index.html b/core/src/components/toast/test/basic/index.html index 71f11271b33..53972953f37 100644 --- a/core/src/components/toast/test/basic/index.html +++ b/core/src/components/toast/test/basic/index.html @@ -23,7 +23,7 @@ Show Toast Bottom Show Toast Top Show Toast Middle - Show Toast with long message + Show Toast with long message Show Toast with Close Button Show Toast with Custom Close Button Text Show Translucent Toast diff --git a/core/src/themes/test/css-variables/index.html b/core/src/themes/test/css-variables/index.html index 3fa7a0899f6..d55c00c03f0 100644 --- a/core/src/themes/test/css-variables/index.html +++ b/core/src/themes/test/css-variables/index.html @@ -48,9 +48,24 @@ - + + + Lists + + + + Colors + + + + Other + + + + + - + Lists
@@ -280,7 +295,7 @@ - + Colors @@ -636,7 +651,7 @@ - + Other @@ -656,12 +671,7 @@
- -
- - -