index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { Component, triggerEventOnly, getValueFromProps, } from '../_util/simply';
  2. import { PopupDefaultProps } from './props';
  3. import { isOldSDKVersion } from '../_util/platform';
  4. var isOldVersion = isOldSDKVersion();
  5. Component(PopupDefaultProps, {
  6. onTapMask: function () {
  7. var closing = this.data.closing;
  8. if (closing) {
  9. return;
  10. }
  11. triggerEventOnly(this, 'close');
  12. },
  13. onAnimationEnd: function () {
  14. var closing = this.data.closing;
  15. if (closing) {
  16. this.setData({ closing: false });
  17. }
  18. var _a = getValueFromProps(this, [
  19. 'visible',
  20. 'duration',
  21. 'animation',
  22. ]), visible = _a[0], duration = _a[1], animation = _a[2];
  23. var enableAnimation = animation && duration > 0;
  24. if (enableAnimation) {
  25. triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
  26. }
  27. },
  28. }, {
  29. closing: false,
  30. isOldVersion: isOldVersion,
  31. }, undefined, {
  32. didUpdate: function (prevProps) {
  33. var _a = getValueFromProps(this, [
  34. 'visible',
  35. 'duration',
  36. 'animation',
  37. ]), visible = _a[0], duration = _a[1], animation = _a[2];
  38. var enableAnimation = animation && duration > 0;
  39. if (prevProps.visible !== visible) {
  40. if (enableAnimation && !visible) {
  41. this.setData({ closing: true });
  42. }
  43. if (!enableAnimation) {
  44. triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
  45. }
  46. }
  47. },
  48. });