UNPKG

2.08 kBJavaScriptView Raw
1'use strict';
2
3const animation = require('./animation-13cbbb20.js');
4const index = require('./index-222357e4.js');
5require('./helpers-d381ec4d.js');
6require('./index-a0a08b2a.js');
7
8const mdTransitionAnimation = (_, opts) => {
9 const OFF_BOTTOM = '40px';
10 const CENTER = '0px';
11 const backDirection = (opts.direction === 'back');
12 const enteringEl = opts.enteringEl;
13 const leavingEl = opts.leavingEl;
14 const ionPageElement = index.getIonPageElement(enteringEl);
15 const enteringToolbarEle = ionPageElement.querySelector('ion-toolbar');
16 const rootTransition = animation.createAnimation();
17 rootTransition
18 .addElement(ionPageElement)
19 .fill('both')
20 .beforeRemoveClass('ion-page-invisible');
21 // animate the component itself
22 if (backDirection) {
23 rootTransition
24 .duration(opts.duration || 200)
25 .easing('cubic-bezier(0.47,0,0.745,0.715)');
26 }
27 else {
28 rootTransition
29 .duration(opts.duration || 280)
30 .easing('cubic-bezier(0.36,0.66,0.04,1)')
31 .fromTo('transform', `translateY(${OFF_BOTTOM})`, `translateY(${CENTER})`)
32 .fromTo('opacity', 0.01, 1);
33 }
34 // Animate toolbar if it's there
35 if (enteringToolbarEle) {
36 const enteringToolBar = animation.createAnimation();
37 enteringToolBar.addElement(enteringToolbarEle);
38 rootTransition.addAnimation(enteringToolBar);
39 }
40 // setup leaving view
41 if (leavingEl && backDirection) {
42 // leaving content
43 rootTransition
44 .duration(opts.duration || 200)
45 .easing('cubic-bezier(0.47,0,0.745,0.715)');
46 const leavingPage = animation.createAnimation();
47 leavingPage
48 .addElement(index.getIonPageElement(leavingEl))
49 .onFinish(currentStep => {
50 if (currentStep === 1 && leavingPage.elements.length > 0) {
51 leavingPage.elements[0].style.setProperty('display', 'none');
52 }
53 })
54 .fromTo('transform', `translateY(${CENTER})`, `translateY(${OFF_BOTTOM})`)
55 .fromTo('opacity', 1, 0);
56 rootTransition.addAnimation(leavingPage);
57 }
58 return rootTransition;
59};
60
61exports.mdTransitionAnimation = mdTransitionAnimation;