index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import baseComponent from '../helpers/baseComponent'
  2. baseComponent({
  3. properties: {
  4. prefixCls: {
  5. type: String,
  6. value: 'wux-backdrop',
  7. },
  8. transparent: {
  9. type: Boolean,
  10. value: false,
  11. },
  12. zIndex: {
  13. type: Number,
  14. value: 1000,
  15. },
  16. classNames: {
  17. type: null,
  18. value: 'wux-animate--fadeIn',
  19. },
  20. },
  21. computed: {
  22. classes() {
  23. const { prefixCls, transparent } = this.data
  24. const wrap = transparent ? `${prefixCls}--transparent` : prefixCls
  25. return {
  26. wrap,
  27. }
  28. },
  29. },
  30. methods: {
  31. /**
  32. * 保持锁定
  33. */
  34. retain() {
  35. if (typeof this.backdropHolds !== 'number' || !this.backdropHolds) {
  36. this.backdropHolds = 0
  37. }
  38. this.backdropHolds = this.backdropHolds + 1
  39. if (this.backdropHolds === 1) {
  40. this.setData({ in: true })
  41. }
  42. },
  43. /**
  44. * 释放锁定
  45. */
  46. release() {
  47. if (this.backdropHolds === 1) {
  48. this.setData({ in: false })
  49. }
  50. this.backdropHolds = Math.max(0, this.backdropHolds - 1)
  51. },
  52. /**
  53. * 点击事件
  54. */
  55. onClick() {
  56. this.triggerEvent('click')
  57. },
  58. },
  59. })