swiper-nav.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 { DIRECTION } from './common/constants';
  10. const { prefix } = config;
  11. let SwiperNav = class SwiperNav extends SuperComponent {
  12. constructor() {
  13. super(...arguments);
  14. this.externalClasses = [`${prefix}-class`];
  15. this.properties = {
  16. type: {
  17. type: String,
  18. value: "dots",
  19. },
  20. minShowNum: {
  21. type: Number,
  22. value: 2,
  23. },
  24. hasNavBtn: {
  25. type: Boolean,
  26. value: false,
  27. },
  28. };
  29. this.relations = {
  30. './swiper': {
  31. type: 'parent',
  32. },
  33. };
  34. this.data = {
  35. index: 0,
  36. total: 0,
  37. direction: DIRECTION.HOR,
  38. prefix,
  39. classPrefix: `${prefix}-swiper-nav`,
  40. };
  41. }
  42. ready() {
  43. var _a;
  44. this.$swiper = (_a = this.getRelationNodes('./swiper')) === null || _a === void 0 ? void 0 : _a[0];
  45. }
  46. onChange(opt) {
  47. this.setData(Object.assign({}, opt));
  48. }
  49. nav(e) {
  50. var _a, _b;
  51. const { dir } = e.target.dataset;
  52. const opt = { source: 'nav', cycle: true };
  53. this.triggerEvent('navBtnChange', Object.assign(Object.assign({}, opt), { dir }));
  54. if (this.$swiper) {
  55. (_a = this.$swiper) === null || _a === void 0 ? void 0 : _a.pause();
  56. (_b = this.$swiper) === null || _b === void 0 ? void 0 : _b[dir](opt);
  57. }
  58. }
  59. };
  60. SwiperNav = __decorate([
  61. wxComponent()
  62. ], SwiperNav);
  63. export default SwiperNav;