swiper.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * 轮播组件
  3. * 因原生swiper受限,基于wxs重新实现,后期可以扩展更多丰富的功能
  4. * todo:无限循环,3D动效等
  5. */
  6. import { SuperComponent, ControlInstance } from '../common/src/index';
  7. interface SwitchOpt {
  8. cycle?: boolean;
  9. source: 'autoplay' | 'touch' | 'nav';
  10. }
  11. export default class Swiper extends SuperComponent {
  12. externalClasses: string[];
  13. options: {
  14. multipleSlots: boolean;
  15. };
  16. properties: import("./type").TdSwiperProps;
  17. observers: {
  18. navigation(val: any): void;
  19. current(val: any): void;
  20. autoplay(val: any): void;
  21. interval(val: any): void;
  22. direction(val: any): void;
  23. };
  24. children: any;
  25. $nav: any;
  26. timer: any;
  27. updateTimer: any;
  28. control: ControlInstance;
  29. relations: {
  30. './swiper-item': {
  31. type: "child";
  32. linked: () => void;
  33. };
  34. './swiper-nav': {
  35. type: "child";
  36. };
  37. };
  38. data: {
  39. _current: number;
  40. _navigation: any;
  41. _width: number;
  42. _height: number;
  43. offsetX: number;
  44. offsetY: number;
  45. total: number;
  46. easings: {
  47. linear: string;
  48. easeInCubic: string;
  49. easeOutCubic: string;
  50. easeInOutCubic: string;
  51. };
  52. inited: boolean;
  53. currentInited: boolean;
  54. prefix: string;
  55. classPrefix: string;
  56. };
  57. attached(): void;
  58. detached(): void;
  59. ready(): void;
  60. /**
  61. * 初始化 swiper-item
  62. */
  63. initItem(): void;
  64. /**
  65. * 初始化 swiper-nav
  66. */
  67. initNav(): void;
  68. /**
  69. * 初始化也需要等待wxs完成,由wxs触发inited
  70. */
  71. inited(): void;
  72. /**
  73. * 初始化current
  74. * 需要通过wxs更新位置,存在短暂延迟
  75. */
  76. initCurrent(): void;
  77. play(): void;
  78. replay(): void;
  79. pause(): void;
  80. /**
  81. * 跳转目标页
  82. * @param index 目标页索引
  83. * @param source 来源标记
  84. * @returns
  85. */
  86. goto(index: number, source: string): void;
  87. /**
  88. * 更新目标页
  89. * @param index 目标页索引(一页可能有多个item)
  90. * @returns
  91. */
  92. update(index: number, finish?: any): void;
  93. /**
  94. * 更新导航器
  95. * @param index
  96. */
  97. updateNav(index: any): void;
  98. calcOffset(index: number): {
  99. offsetX: number;
  100. offsetY?: undefined;
  101. } | {
  102. offsetY: number;
  103. offsetX?: undefined;
  104. };
  105. /**
  106. * 下一页
  107. * @param opt
  108. */
  109. next(opt: SwitchOpt): void;
  110. /**
  111. * 上一页
  112. * @param opt
  113. */
  114. prev(opt: SwitchOpt): void;
  115. /**
  116. * 内置导航组件,监听按钮点击
  117. * @param e
  118. */
  119. onSwiperNavBtnChange(e: any): void;
  120. }
  121. export {};