overlay.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. };
  33. this.behaviors = [transition()];
  34. this.data = {
  35. prefix,
  36. classPrefix: name,
  37. computedStyle: '',
  38. _zIndex: 11000,
  39. };
  40. this.observers = {
  41. backgroundColor(v) {
  42. this.setData({
  43. computedStyle: `background-color: ${v};`,
  44. });
  45. },
  46. zIndex(v) {
  47. if (v !== 0) {
  48. this.setData({
  49. _zIndex: v,
  50. });
  51. }
  52. },
  53. };
  54. this.methods = {
  55. handleClick() {
  56. this.triggerEvent('click', { visible: !this.properties.visible });
  57. },
  58. noop() { },
  59. };
  60. }
  61. };
  62. Overlay = __decorate([
  63. wxComponent()
  64. ], Overlay);
  65. export default Overlay;