overlay.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. import { SuperComponent, wxComponent } from '../common/src/index';
  8. import config from '../common/config';
  9. import transition from '../mixins/transition';
  10. const { prefix } = config;
  11. const name = `${prefix}-overlay`;
  12. let Overlay = class Overlay extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.properties = {
  16. zIndex: {
  17. type: Number,
  18. value: 11000,
  19. },
  20. duration: {
  21. type: Number,
  22. value: 300,
  23. },
  24. backgroundColor: {
  25. type: String,
  26. value: '',
  27. },
  28. preventScrollThrough: {
  29. type: Boolean,
  30. value: true,
  31. },
  32. customStyle: {
  33. type: String,
  34. value: '',
  35. },
  36. };
  37. this.behaviors = [transition()];
  38. this.data = {
  39. prefix,
  40. classPrefix: name,
  41. computedStyle: '',
  42. _zIndex: 11000,
  43. };
  44. this.observers = {
  45. backgroundColor(v) {
  46. this.setData({
  47. computedStyle: `background-color: ${v};`,
  48. });
  49. },
  50. zIndex(v) {
  51. if (v !== 0) {
  52. this.setData({
  53. _zIndex: v,
  54. });
  55. }
  56. },
  57. };
  58. this.methods = {
  59. handleClick() {
  60. this.triggerEvent('click', { visible: !this.properties.visible });
  61. },
  62. noop() { },
  63. };
  64. }
  65. };
  66. Overlay = __decorate([
  67. wxComponent()
  68. ], Overlay);
  69. export default Overlay;