swiper-item.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 { DIRECTION } from './common/constants';
  9. import config from '../common/config';
  10. const { prefix } = config;
  11. let SwiperItem = class SwiperItem extends SuperComponent {
  12. constructor() {
  13. super(...arguments);
  14. this.relations = {
  15. './swiper': {
  16. type: 'parent',
  17. },
  18. };
  19. this.data = {
  20. index: 0,
  21. classPrefix: `${prefix}-swiper-item`,
  22. translate: '',
  23. };
  24. }
  25. setIndex(index, direction) {
  26. const translate = direction === DIRECTION.HOR ? `translate(${100 * index}%, 0px)` : `translate(0px, ${100 * index}%)`;
  27. this.setData({
  28. index,
  29. direction,
  30. translate,
  31. });
  32. }
  33. };
  34. SwiperItem = __decorate([
  35. wxComponent()
  36. ], SwiperItem);
  37. export default SwiperItem;