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: ['prefixCls, transparent', function(prefixCls, transparent) {
  23. const wrap = transparent ? `${prefixCls}--transparent` : prefixCls
  24. return {
  25. wrap,
  26. }
  27. }],
  28. },
  29. methods: {
  30. /**
  31. * 保持锁定
  32. */
  33. retain() {
  34. if (typeof this.backdropHolds !== 'number' || !this.backdropHolds) {
  35. this.backdropHolds = 0
  36. }
  37. this.backdropHolds = this.backdropHolds + 1
  38. if (this.backdropHolds === 1) {
  39. this.setData({ in: true })
  40. }
  41. },
  42. /**
  43. * 释放锁定
  44. */
  45. release() {
  46. if (this.backdropHolds === 1) {
  47. this.setData({ in: false })
  48. }
  49. this.backdropHolds = Math.max(0, this.backdropHolds - 1)
  50. },
  51. /**
  52. * 点击事件
  53. */
  54. onClick() {
  55. this.triggerEvent('click')
  56. },
  57. },
  58. })