md.transition-e018ebe5.js 2.4 KB

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