index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var component_1 = require('../common/component');
  4. var transition_1 = require('../mixins/transition');
  5. component_1.VantComponent({
  6. classes: [
  7. 'enter-class',
  8. 'enter-active-class',
  9. 'enter-to-class',
  10. 'leave-class',
  11. 'leave-active-class',
  12. 'leave-to-class',
  13. 'close-icon-class',
  14. ],
  15. mixins: [transition_1.transition(false)],
  16. props: {
  17. round: Boolean,
  18. closeable: Boolean,
  19. customStyle: String,
  20. overlayStyle: String,
  21. transition: {
  22. type: String,
  23. observer: 'observeClass',
  24. },
  25. zIndex: {
  26. type: Number,
  27. value: 100,
  28. },
  29. overlay: {
  30. type: Boolean,
  31. value: true,
  32. },
  33. closeIcon: {
  34. type: String,
  35. value: 'cross',
  36. },
  37. closeIconPosition: {
  38. type: String,
  39. value: 'top-right',
  40. },
  41. closeOnClickOverlay: {
  42. type: Boolean,
  43. value: true,
  44. },
  45. position: {
  46. type: String,
  47. value: 'center',
  48. observer: 'observeClass',
  49. },
  50. safeAreaInsetBottom: {
  51. type: Boolean,
  52. value: true,
  53. },
  54. safeAreaInsetTop: {
  55. type: Boolean,
  56. value: false,
  57. },
  58. },
  59. created: function () {
  60. this.observeClass();
  61. },
  62. methods: {
  63. onClickCloseIcon: function () {
  64. this.$emit('close');
  65. },
  66. onClickOverlay: function () {
  67. this.$emit('click-overlay');
  68. if (this.data.closeOnClickOverlay) {
  69. this.$emit('close');
  70. }
  71. },
  72. observeClass: function () {
  73. var _a = this.data,
  74. transition = _a.transition,
  75. position = _a.position,
  76. duration = _a.duration;
  77. var updateData = {
  78. name: transition || position,
  79. };
  80. if (transition === 'none') {
  81. updateData.duration = 0;
  82. this.originDuration = duration;
  83. } else if (this.originDuration != null) {
  84. updateData.duration = this.originDuration;
  85. }
  86. this.setData(updateData);
  87. },
  88. },
  89. });