index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. lockScroll: {
  59. type: Boolean,
  60. value: true,
  61. },
  62. },
  63. created: function () {
  64. this.observeClass();
  65. },
  66. methods: {
  67. onClickCloseIcon: function () {
  68. this.$emit('close');
  69. },
  70. onClickOverlay: function () {
  71. this.$emit('click-overlay');
  72. if (this.data.closeOnClickOverlay) {
  73. this.$emit('close');
  74. }
  75. },
  76. observeClass: function () {
  77. var _a = this.data,
  78. transition = _a.transition,
  79. position = _a.position,
  80. duration = _a.duration;
  81. var updateData = {
  82. name: transition || position,
  83. };
  84. if (transition === 'none') {
  85. updateData.duration = 0;
  86. this.originDuration = duration;
  87. } else if (this.originDuration != null) {
  88. updateData.duration = this.originDuration;
  89. }
  90. this.setData(updateData);
  91. },
  92. },
  93. });