@autobest-ui/components 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +10 -10
  2. package/esm/accordion/__stories__/style.scss +58 -58
  3. package/esm/affix/__stories__/style.scss +13 -13
  4. package/esm/affix/style/index.scss +34 -34
  5. package/esm/base.scss +42 -42
  6. package/esm/carousel/__stories__/style.scss +41 -41
  7. package/esm/carousel/index.d.ts +21 -13
  8. package/esm/carousel/index.js +77 -44
  9. package/esm/carousel/style/index.css +1 -1
  10. package/esm/carousel/style/index.scss +43 -37
  11. package/esm/checkbox/style/index.scss +117 -117
  12. package/esm/collapse/__stories__/style.scss +18 -18
  13. package/esm/collapse/style/index.scss +42 -42
  14. package/esm/confirm/style/index.scss +44 -44
  15. package/esm/date-picker/calendar/grid/index.scss +85 -85
  16. package/esm/date-picker/calendar/index.scss +57 -57
  17. package/esm/date-picker/style/index.scss +18 -18
  18. package/esm/drawer/style/index.scss +44 -44
  19. package/esm/ellipsis/style/index.scss +35 -35
  20. package/esm/guide/__stories__/style.scss +13 -13
  21. package/esm/guide/style/index.scss +17 -17
  22. package/esm/icon/__stories__/style.scss +39 -39
  23. package/esm/icon/style/index.scss +6 -6
  24. package/esm/index.d.ts +1 -1
  25. package/esm/input-number/style/index.scss +86 -86
  26. package/esm/lazy-image/__stories__/style.scss +9 -9
  27. package/esm/lazy-image/style/index.scss +24 -24
  28. package/esm/link-list/style/index.scss +125 -125
  29. package/esm/loading/style/index.scss +30 -30
  30. package/esm/loading-bar/style/index.scss +62 -62
  31. package/esm/loading-container/__stories__/style.scss +5 -5
  32. package/esm/loading-container/style/index.scss +27 -27
  33. package/esm/loading-icon/style/index.scss +23 -23
  34. package/esm/mask/style/index.scss +34 -34
  35. package/esm/message/style/index.scss +70 -70
  36. package/esm/modal/style/index.scss +112 -112
  37. package/esm/move/__stories__/style.scss +6 -6
  38. package/esm/move/style/index.scss +7 -7
  39. package/esm/popover/__stories__/style.scss +15 -15
  40. package/esm/popover/style/index.scss +59 -59
  41. package/esm/select/__stories__/style.scss +8 -8
  42. package/esm/select/style/index.scss +126 -126
  43. package/esm/show-more/style/index.scss +22 -22
  44. package/esm/skeleton/__stories__/style.scss +2 -2
  45. package/esm/skeleton/style/index.scss +26 -26
  46. package/esm/style.css +15 -15
  47. package/esm/table/__stories__/style.css +1 -1
  48. package/esm/table/__stories__/style.scss +33 -2
  49. package/esm/table/body/BodyRow.d.ts +13 -0
  50. package/esm/table/body/BodyRow.js +94 -0
  51. package/esm/table/body/CheckIcon.d.ts +16 -0
  52. package/esm/table/body/CheckIcon.js +35 -0
  53. package/esm/table/body/index.d.ts +24 -0
  54. package/esm/table/body/index.js +61 -0
  55. package/esm/table/header/CheckIcon.d.ts +13 -0
  56. package/esm/table/header/CheckIcon.js +37 -0
  57. package/esm/table/header/HeaderCell.d.ts +18 -0
  58. package/esm/table/{HeaderCell.js → header/HeaderCell.js} +11 -4
  59. package/esm/table/header/HeaderRow.d.ts +16 -0
  60. package/esm/table/header/HeaderRow.js +76 -0
  61. package/esm/table/index.d.ts +52 -27
  62. package/esm/table/index.js +178 -155
  63. package/esm/table/interface.d.ts +16 -3
  64. package/esm/table/style/index.css +1 -1
  65. package/esm/table/style/index.scss +51 -70
  66. package/esm/tabs/__stories__/style.scss +8 -8
  67. package/esm/tabs/style/index.css +1 -1
  68. package/esm/tabs/style/index.scss +62 -62
  69. package/esm/tooltip/style/index.scss +61 -61
  70. package/esm/trigger/style/index.scss +79 -79
  71. package/lib/accordion/__stories__/style.scss +58 -58
  72. package/lib/affix/__stories__/style.scss +13 -13
  73. package/lib/affix/style/index.scss +34 -34
  74. package/lib/base.scss +42 -42
  75. package/lib/carousel/__stories__/style.scss +41 -41
  76. package/lib/carousel/index.d.ts +21 -13
  77. package/lib/carousel/index.js +80 -45
  78. package/lib/carousel/style/index.css +1 -1
  79. package/lib/carousel/style/index.scss +43 -37
  80. package/lib/checkbox/style/index.scss +117 -117
  81. package/lib/collapse/__stories__/style.scss +18 -18
  82. package/lib/collapse/style/index.scss +42 -42
  83. package/lib/confirm/style/index.scss +44 -44
  84. package/lib/date-picker/calendar/grid/index.scss +85 -85
  85. package/lib/date-picker/calendar/index.scss +57 -57
  86. package/lib/date-picker/style/index.scss +18 -18
  87. package/lib/drawer/style/index.scss +44 -44
  88. package/lib/ellipsis/style/index.scss +35 -35
  89. package/lib/guide/__stories__/style.scss +13 -13
  90. package/lib/guide/style/index.scss +17 -17
  91. package/lib/icon/__stories__/style.scss +39 -39
  92. package/lib/icon/style/index.scss +6 -6
  93. package/lib/index.d.ts +1 -1
  94. package/lib/input-number/style/index.scss +86 -86
  95. package/lib/lazy-image/__stories__/style.scss +9 -9
  96. package/lib/lazy-image/style/index.scss +24 -24
  97. package/lib/link-list/style/index.scss +125 -125
  98. package/lib/loading/style/index.scss +30 -30
  99. package/lib/loading-bar/style/index.scss +62 -62
  100. package/lib/loading-container/__stories__/style.scss +5 -5
  101. package/lib/loading-container/style/index.scss +27 -27
  102. package/lib/loading-icon/style/index.scss +23 -23
  103. package/lib/mask/style/index.scss +34 -34
  104. package/lib/message/style/index.scss +70 -70
  105. package/lib/modal/style/index.scss +112 -112
  106. package/lib/move/__stories__/style.scss +6 -6
  107. package/lib/move/style/index.scss +7 -7
  108. package/lib/popover/__stories__/style.scss +15 -15
  109. package/lib/popover/style/index.scss +59 -59
  110. package/lib/select/__stories__/style.scss +8 -8
  111. package/lib/select/style/index.scss +126 -126
  112. package/lib/show-more/style/index.scss +22 -22
  113. package/lib/skeleton/__stories__/style.scss +2 -2
  114. package/lib/skeleton/style/index.scss +26 -26
  115. package/lib/style.css +15 -15
  116. package/lib/table/__stories__/style.css +1 -1
  117. package/lib/table/__stories__/style.scss +33 -2
  118. package/lib/table/body/BodyRow.d.ts +13 -0
  119. package/lib/table/body/BodyRow.js +108 -0
  120. package/lib/table/body/CheckIcon.d.ts +16 -0
  121. package/lib/table/body/CheckIcon.js +47 -0
  122. package/lib/table/body/index.d.ts +24 -0
  123. package/lib/table/body/index.js +73 -0
  124. package/lib/table/header/CheckIcon.d.ts +13 -0
  125. package/lib/table/header/CheckIcon.js +49 -0
  126. package/lib/table/header/HeaderCell.d.ts +18 -0
  127. package/lib/table/{HeaderCell.js → header/HeaderCell.js} +11 -4
  128. package/lib/table/header/HeaderRow.d.ts +16 -0
  129. package/lib/table/header/HeaderRow.js +89 -0
  130. package/lib/table/index.d.ts +52 -27
  131. package/lib/table/index.js +177 -155
  132. package/lib/table/interface.d.ts +16 -3
  133. package/lib/table/style/index.css +1 -1
  134. package/lib/table/style/index.scss +51 -70
  135. package/lib/tabs/__stories__/style.scss +8 -8
  136. package/lib/tabs/style/index.css +1 -1
  137. package/lib/tabs/style/index.scss +62 -62
  138. package/lib/tooltip/style/index.scss +61 -61
  139. package/lib/trigger/style/index.scss +79 -79
  140. package/package.json +2 -2
  141. package/esm/table/BodyCell.d.ts +0 -6
  142. package/esm/table/BodyCell.js +0 -12
  143. package/esm/table/HeaderCell.d.ts +0 -13
  144. package/lib/table/BodyCell.d.ts +0 -6
  145. package/lib/table/BodyCell.js +0 -22
  146. package/lib/table/HeaderCell.d.ts +0 -13
@@ -1,13 +1,13 @@
1
- .affix-demo {
2
- height: 200vh;
3
- overflow: auto;
4
- width: 1000px;
5
- max-width: 100%;
6
- margin: auto;
7
-
8
- .affix-wrap {
9
- height: 500px;
10
- width: 100%;
11
- background-color: #D1D5DB;
12
- }
13
- }
1
+ .affix-demo {
2
+ height: 200vh;
3
+ overflow: auto;
4
+ width: 1000px;
5
+ max-width: 100%;
6
+ margin: auto;
7
+
8
+ .affix-wrap {
9
+ height: 500px;
10
+ width: 100%;
11
+ background-color: #D1D5DB;
12
+ }
13
+ }
@@ -1,35 +1,35 @@
1
- $namespace: ab-affix;
2
- $customFade: #{$namespace}-fade;
3
-
4
- .#{$namespace} {
5
- &, &-custom {
6
- z-index: 100;
7
- }
8
-
9
- &-custom {
10
- position: fixed;
11
- transition: transform 200ms cubic-bezier(.7, .3, .1, 1);
12
- }
13
- }
14
-
15
- .#{$customFade} {
16
- &-enter, &-appear {
17
- transform: translate(0, -100%)
18
- }
19
-
20
- &-enter-active, &-appear-active {
21
- transform: translate(0, 0);
22
- }
23
-
24
- &-exit {
25
- transform: translate(0, 0);
26
- }
27
-
28
- &-exit-active {
29
- transform: translate(0, -100%)
30
- }
31
-
32
- &-exit-done {
33
- display: none;
34
- }
1
+ $namespace: ab-affix;
2
+ $customFade: #{$namespace}-fade;
3
+
4
+ .#{$namespace} {
5
+ &, &-custom {
6
+ z-index: 100;
7
+ }
8
+
9
+ &-custom {
10
+ position: fixed;
11
+ transition: transform 200ms cubic-bezier(.7, .3, .1, 1);
12
+ }
13
+ }
14
+
15
+ .#{$customFade} {
16
+ &-enter, &-appear {
17
+ transform: translate(0, -100%)
18
+ }
19
+
20
+ &-enter-active, &-appear-active {
21
+ transform: translate(0, 0);
22
+ }
23
+
24
+ &-exit {
25
+ transform: translate(0, 0);
26
+ }
27
+
28
+ &-exit-active {
29
+ transform: translate(0, -100%)
30
+ }
31
+
32
+ &-exit-done {
33
+ display: none;
34
+ }
35
35
  }
package/lib/base.scss CHANGED
@@ -1,42 +1,42 @@
1
- /* reset css */
2
- html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video, input, a, textarea {
3
- box-sizing: border-box;
4
- }
5
-
6
- html {
7
- font-size: 100px;
8
- font-family: Arial, sans-serif;
9
- touch-action: manipulation;
10
- -ms-touch-action: manipulation;
11
- }
12
-
13
- @media only screen and (max-width: 767px) {
14
- html {
15
- //font-size: 24.15459vw;
16
- // 暂时取消对UI自适应,而是统一成一种
17
- font-size: 100px;
18
- }
19
- }
20
-
21
- body {
22
- font-size: .12rem;
23
- color: #333;
24
- margin: 0;
25
- padding: 0;
26
- -webkit-font-smoothing: antialiased;
27
- -moz-osx-font-smoothing: grayscale;
28
- }
29
-
30
- a {
31
- text-decoration: none;
32
- }
33
-
34
- input {
35
- outline: none;
36
- }
37
-
38
- ul, li {
39
- padding: 0;
40
- margin: 0;
41
- list-style: none;
42
- }
1
+ /* reset css */
2
+ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video, input, a, textarea {
3
+ box-sizing: border-box;
4
+ }
5
+
6
+ html {
7
+ font-size: 100px;
8
+ font-family: Arial, sans-serif;
9
+ touch-action: manipulation;
10
+ -ms-touch-action: manipulation;
11
+ }
12
+
13
+ @media only screen and (max-width: 767px) {
14
+ html {
15
+ //font-size: 24.15459vw;
16
+ // 暂时取消对UI自适应,而是统一成一种
17
+ font-size: 100px;
18
+ }
19
+ }
20
+
21
+ body {
22
+ font-size: .12rem;
23
+ color: #333;
24
+ margin: 0;
25
+ padding: 0;
26
+ -webkit-font-smoothing: antialiased;
27
+ -moz-osx-font-smoothing: grayscale;
28
+ }
29
+
30
+ a {
31
+ text-decoration: none;
32
+ }
33
+
34
+ input {
35
+ outline: none;
36
+ }
37
+
38
+ ul, li {
39
+ padding: 0;
40
+ margin: 0;
41
+ list-style: none;
42
+ }
@@ -1,41 +1,41 @@
1
- .demo-carousel {
2
- margin: auto;
3
- position: relative;
4
-
5
- p {
6
- display: flex;
7
- align-items: center;
8
- justify-content: center;
9
- font-size: 32px;
10
- margin: 0;
11
- color: #F3F4F6;
12
- height: 225px;
13
- border-radius: 3px;
14
- }
15
- }
16
-
17
- .ab-carousel {
18
- position: relative;
19
- }
20
-
21
- .button-prev, .button-next {
22
- position: absolute;
23
- box-sizing: border-box;
24
- cursor: pointer;
25
- font-size: 32px;
26
- top: 50%;
27
- margin-top: -15px;
28
- width: 30px;
29
- height: 30px;
30
- color: #F3F4F6;
31
- }
32
-
33
- .button-prev {
34
- left: 5px;
35
- top: 50%;
36
- }
37
-
38
- .button-next {
39
- right: 5px;
40
- top: 50%;
41
- }
1
+ .demo-carousel {
2
+ margin: auto;
3
+ position: relative;
4
+
5
+ p {
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ font-size: 32px;
10
+ margin: 0;
11
+ color: #F3F4F6;
12
+ height: 225px;
13
+ border-radius: 3px;
14
+ }
15
+ }
16
+
17
+ .ab-carousel {
18
+ position: relative;
19
+ }
20
+
21
+ .button-prev, .button-next {
22
+ position: absolute;
23
+ box-sizing: border-box;
24
+ cursor: pointer;
25
+ font-size: 32px;
26
+ top: 50%;
27
+ margin-top: -15px;
28
+ width: 30px;
29
+ height: 30px;
30
+ color: #F3F4F6;
31
+ }
32
+
33
+ .button-prev {
34
+ left: 5px;
35
+ top: 50%;
36
+ }
37
+
38
+ .button-next {
39
+ right: 5px;
40
+ top: 50%;
41
+ }
@@ -1,11 +1,19 @@
1
1
  import React from 'react';
2
2
  import { AddListenerEventHandler } from '@autobest-ui/utils';
3
+ export declare enum CarouselDirection {
4
+ vertical = "vertical",
5
+ horizontal = "horizontal"
6
+ }
3
7
  export interface CarouselProps {
4
8
  children: React.ReactElement[] | React.ReactElement;
5
9
  /**
6
10
  * 一行显示的数量
7
11
  */
8
12
  slidesPerView?: number;
13
+ /**
14
+ * 滚动方向
15
+ */
16
+ direction?: CarouselDirection;
9
17
  /**
10
18
  * 监听resize
11
19
  */
@@ -14,10 +22,6 @@ export interface CarouselProps {
14
22
  * 是否可以手动控制 只支持移动端
15
23
  */
16
24
  controllable?: boolean;
17
- /**
18
- * 组件高度,可以不写,不写情况下,自动获取高度
19
- */
20
- height?: string;
21
25
  /**
22
26
  * 敏感值,设置多少后可以进行切换, 只有在 controllable = true时生效
23
27
  */
@@ -53,17 +57,18 @@ interface CarouselStates {
53
57
  declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
54
58
  readonly prefixCls = "ab-carousel";
55
59
  listRef: React.RefObject<HTMLDivElement>;
56
- sliderWidth: number;
57
- contentWidth: number;
58
- isDirectionLeft: boolean;
60
+ sliderSize: number;
61
+ contentSize: number;
62
+ isDirectionLeftOrTop: boolean;
59
63
  intersectionObserver: IntersectionObserver;
60
- startX: number;
61
- prevX: number;
62
- moveX: number;
63
- endX: number;
64
+ startSize: number;
65
+ prevSize: number;
66
+ moveSize: number;
67
+ endSize: number;
64
68
  autoplayTimer: any;
65
69
  fadeEffectTimer: any;
66
70
  static defaultProps: {
71
+ direction: CarouselDirection;
67
72
  slidesPerView: number;
68
73
  defaultValue: number;
69
74
  className: string;
@@ -82,6 +87,8 @@ declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
82
87
  next: (transition?: string) => void;
83
88
  prev: (transition?: string) => void;
84
89
  goTo: (nextIndex: number, transition?: string) => void;
90
+ isHorizontalDirection: () => boolean;
91
+ setElementSizeByDirection: (element: HTMLElement, value: string) => void;
85
92
  /**
86
93
  * 获取滚动元素数量
87
94
  */
@@ -103,10 +110,11 @@ declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
103
110
  /**
104
111
  * 设置容器元素样式,分别是:透明度渐变与位置偏移
105
112
  * @param element
106
- * @param translateX
113
+ * @param translateSize
107
114
  * @param transition
108
115
  */
109
- setListStyles: (element: HTMLElement, translateX: number, transition?: string) => void;
116
+ setListStyles: (element: HTMLElement, translateSize: number, transition?: string) => void;
117
+ getTouchSize: (event: any) => any;
110
118
  /**
111
119
  * 开启自动偏移或者渐变,当元素少于2时,将不会开启
112
120
  */
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.CarouselDirection = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
@@ -41,6 +41,14 @@ var __extends = void 0 && (void 0).__extends || function () {
41
41
  };
42
42
  }();
43
43
 
44
+ var CarouselDirection;
45
+ exports.CarouselDirection = CarouselDirection;
46
+
47
+ (function (CarouselDirection) {
48
+ CarouselDirection["vertical"] = "vertical";
49
+ CarouselDirection["horizontal"] = "horizontal";
50
+ })(CarouselDirection || (exports.CarouselDirection = CarouselDirection = {}));
51
+
44
52
  var Carousel =
45
53
  /** @class */
46
54
  function (_super) {
@@ -50,14 +58,15 @@ function (_super) {
50
58
  var _this = _super.call(this, props) || this;
51
59
 
52
60
  _this.prefixCls = 'ab-carousel';
53
- _this.listRef = _react.default.createRef();
54
- _this.sliderWidth = 0;
55
- _this.contentWidth = 0;
56
- _this.isDirectionLeft = true;
57
- _this.startX = 0;
58
- _this.prevX = 0;
59
- _this.moveX = 0;
60
- _this.endX = 0;
61
+ _this.listRef = _react.default.createRef(); // 当是horizontal时是width, 否则是height
62
+
63
+ _this.sliderSize = 0;
64
+ _this.contentSize = 0;
65
+ _this.isDirectionLeftOrTop = true;
66
+ _this.startSize = 0;
67
+ _this.prevSize = 0;
68
+ _this.moveSize = 0;
69
+ _this.endSize = 0;
61
70
  _this.autoplayTimer = null;
62
71
  _this.fadeEffectTimer = null;
63
72
 
@@ -72,6 +81,20 @@ function (_super) {
72
81
  _this.goTo = function (nextIndex, transition) {
73
82
  _this.interceptorChangePage(nextIndex - 1, transition);
74
83
  };
84
+
85
+ _this.isHorizontalDirection = function () {
86
+ return _this.props.direction === CarouselDirection.horizontal;
87
+ };
88
+
89
+ _this.setElementSizeByDirection = function (element, value) {
90
+ var isHr = _this.isHorizontalDirection();
91
+
92
+ if (isHr) {
93
+ element.style.width = value;
94
+ } else {
95
+ element.style.height = value;
96
+ }
97
+ };
75
98
  /**
76
99
  * 获取滚动元素数量
77
100
  */
@@ -104,11 +127,14 @@ function (_super) {
104
127
  return;
105
128
  }
106
129
 
130
+ var isHr = _this.isHorizontalDirection();
131
+
107
132
  var childCount = _this.getChildCount();
108
133
 
109
- _this.contentWidth = (0, _utils.getElementSize)(element.parentNode).width; // 没有子元素或者获取不到宽度
134
+ var parentNodeOffset = (0, _utils.getElementSize)(element.parentNode);
135
+ _this.contentSize = isHr ? parentNodeOffset.width : parentNodeOffset.height; // 没有子元素或者获取不到宽度
110
136
 
111
- if (!childCount || !_this.contentWidth) {
137
+ if (!childCount || !_this.contentSize) {
112
138
  return;
113
139
  } // 执行一次,控制样式,显示slider
114
140
 
@@ -120,23 +146,18 @@ function (_super) {
120
146
  }
121
147
 
122
148
  var currentPage = _this.state.currentPage;
123
- var _a = _this.props,
124
- slidesPerView = _a.slidesPerView,
125
- height = _a.height;
126
- _this.sliderWidth = _this.contentWidth / slidesPerView;
127
- element.style.width = _this.sliderWidth * childCount + "px";
149
+ var slidesPerView = _this.props.slidesPerView;
150
+ _this.sliderSize = _this.contentSize / slidesPerView;
128
151
 
129
- if (height) {
130
- element.style.height = height;
131
- }
152
+ _this.setElementSizeByDirection(element, _this.sliderSize * childCount + "px");
132
153
 
133
154
  var childList = Array.from(element.children);
134
155
  childList.forEach(function (child) {
135
- child.style.width = _this.sliderWidth + "px";
156
+ _this.setElementSizeByDirection(child, _this.sliderSize + "px");
136
157
  });
137
- _this.prevX = -currentPage * _this.sliderWidth;
158
+ _this.prevSize = -currentPage * _this.sliderSize;
138
159
 
139
- _this.setListStyles(element, _this.prevX);
160
+ _this.setListStyles(element, _this.prevSize);
140
161
 
141
162
  _this.onAutoplay();
142
163
  };
@@ -173,11 +194,11 @@ function (_super) {
173
194
  nextPage = 0;
174
195
  }
175
196
 
176
- _this.prevX = -nextPage * _this.sliderWidth;
197
+ _this.prevSize = -nextPage * _this.sliderSize;
177
198
 
178
199
  _this.onBeforeChange(nextPage);
179
200
 
180
- _this.setListStyles(element, _this.prevX, transition);
201
+ _this.setListStyles(element, _this.prevSize, transition);
181
202
 
182
203
  _this.setState({
183
204
  currentPage: nextPage
@@ -190,12 +211,12 @@ function (_super) {
190
211
  /**
191
212
  * 设置容器元素样式,分别是:透明度渐变与位置偏移
192
213
  * @param element
193
- * @param translateX
214
+ * @param translateSize
194
215
  * @param transition
195
216
  */
196
217
 
197
218
 
198
- _this.setListStyles = function (element, translateX, transition) {
219
+ _this.setListStyles = function (element, translateSize, transition) {
199
220
  element.style.transition = ''; // 当开启渐变时,直接执行渐变,将没有位置偏移动画
200
221
 
201
222
  if (_this.props.fadeEffect) {
@@ -211,7 +232,17 @@ function (_super) {
211
232
  element.style.transition = transition || _transition.default.TransformEaseInOut;
212
233
  }
213
234
 
214
- element.style.transform = "translateX(" + translateX + "px)";
235
+ element.style.transform = _this.isHorizontalDirection() ? "translateX(" + translateSize + "px)" : "translateY(" + translateSize + "px)";
236
+ };
237
+
238
+ _this.getTouchSize = function (event) {
239
+ var isHr = _this.isHorizontalDirection();
240
+
241
+ if (event.touches) {
242
+ return isHr ? event.touches[0].pageX : event.touches[0].pageY;
243
+ }
244
+
245
+ return isHr ? event.clientX : event.clientY;
215
246
  };
216
247
 
217
248
  _this.onBeforeChange = function (currentPage) {
@@ -248,8 +279,8 @@ function (_super) {
248
279
 
249
280
  event.preventDefault();
250
281
  clearTimeout(_this.autoplayTimer);
251
- _this.endX = 0;
252
- _this.startX = event.touches ? event.touches[0].pageX : event.clientX;
282
+ _this.endSize = 0;
283
+ _this.startSize = _this.getTouchSize(event);
253
284
 
254
285
  var element = _this.getListDomNode();
255
286
 
@@ -271,9 +302,9 @@ function (_super) {
271
302
  }
272
303
 
273
304
  event.preventDefault();
274
- _this.endX = event.touches ? event.touches[0].pageX : event.clientX;
275
- _this.moveX = _this.prevX + _this.endX - _this.startX;
276
- _this.isDirectionLeft = _this.prevX - _this.startX <= _this.prevX - _this.endX;
305
+ _this.endSize = _this.getTouchSize(event);
306
+ _this.moveSize = _this.prevSize + _this.endSize - _this.startSize;
307
+ _this.isDirectionLeftOrTop = _this.prevSize - _this.startSize <= _this.prevSize - _this.endSize;
277
308
 
278
309
  var element = _this.getListDomNode();
279
310
 
@@ -281,7 +312,7 @@ function (_super) {
281
312
  return;
282
313
  }
283
314
 
284
- element.style.transform = "translateX(" + _this.moveX + "px)";
315
+ element.style.transform = _this.isHorizontalDirection() ? "translateX(" + _this.moveSize + "px)" : "translateY(" + _this.moveSize + "px)";
285
316
  };
286
317
  /**
287
318
  * 停止滑动,判断用户移动位置,确定用户最终滑动位置
@@ -308,9 +339,9 @@ function (_super) {
308
339
  var currentPage = _this.state.currentPage;
309
340
  var transition = _transition.default.TransformEaseOut; // 移动的偏移量
310
341
 
311
- var translateX = Math.abs(_this.startX - _this.endX); // 判断用户未产生滑动,认为是点击
342
+ var translateSize = Math.abs(_this.startSize - _this.endSize); // 判断用户未产生滑动,认为是点击
312
343
 
313
- if (_this.endX === 0 || translateX < sensitivity) {
344
+ if (_this.endSize === 0 || translateSize < sensitivity) {
314
345
  if (onClick) {
315
346
  onClick(_this.state.currentPage + 1);
316
347
  }
@@ -322,7 +353,7 @@ function (_super) {
322
353
 
323
354
  event.preventDefault(); // 移出左边临界点
324
355
 
325
- if (_this.moveX >= 0) {
356
+ if (_this.moveSize >= 0) {
326
357
  _this.interceptorChangePage(0, transition);
327
358
 
328
359
  return;
@@ -331,21 +362,21 @@ function (_super) {
331
362
  var childCount = _this.getChildCount(); // 移出右边临界点
332
363
 
333
364
 
334
- var listWidth = _this.sliderWidth * childCount;
335
- var moveX = Math.abs(_this.moveX);
365
+ var listSize = _this.sliderSize * childCount;
366
+ var moveX = Math.abs(_this.moveSize);
336
367
 
337
- if (moveX >= listWidth - _this.contentWidth) {
368
+ if (moveX >= listSize - _this.contentSize) {
338
369
  _this.interceptorChangePage(childCount - slidesPerView, transition);
339
370
 
340
371
  return;
341
372
  } // 未达到一页,判断是否超出sensitivity, 超出将加1
342
373
 
343
374
 
344
- var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
375
+ var skipOne = translateSize % _this.sliderSize >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
345
376
 
346
- var skipCount = Math.floor(translateX / _this.sliderWidth); // 判断是否向左滑动
377
+ var skipCount = Math.floor(translateSize / _this.sliderSize); // 判断是否向左滑动
347
378
 
348
- if (_this.isDirectionLeft) {
379
+ if (_this.isDirectionLeftOrTop) {
349
380
  currentPage = currentPage + skipCount + skipOne;
350
381
  } else {
351
382
  currentPage -= skipCount + skipOne;
@@ -388,9 +419,11 @@ function (_super) {
388
419
  Carousel.prototype.componentDidUpdate = function (prevProps) {
389
420
  var _this = this;
390
421
 
391
- var children = this.props.children;
422
+ var _a = this.props,
423
+ children = _a.children,
424
+ direction = _a.direction;
392
425
 
393
- if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children)) {
426
+ if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children) || direction !== prevProps.direction) {
394
427
  this.init();
395
428
  } // 加入 resize 监听
396
429
 
@@ -441,8 +474,9 @@ function (_super) {
441
474
  className = _b.className,
442
475
  children = _b.children,
443
476
  pagination = _b.pagination;
477
+ var isHr = this.isHorizontalDirection();
444
478
  return _react.default.createElement("div", {
445
- className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a))
479
+ className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a[cls + "-hr"] = isHr, _a[cls + "-vt"] = !isHr, _a))
446
480
  }, _react.default.createElement("div", {
447
481
  className: cls + "-content"
448
482
  }, _react.default.createElement("div", {
@@ -463,6 +497,7 @@ function (_super) {
463
497
 
464
498
 
465
499
  Carousel.defaultProps = {
500
+ direction: CarouselDirection.horizontal,
466
501
  slidesPerView: 1,
467
502
  defaultValue: 1,
468
503
  className: '',
@@ -1 +1 @@
1
- .ab-carousel{position:relative}.ab-carousel-content{position:relative;display:block;height:100%;width:100%;margin:0;padding:0;overflow:hidden}.ab-carousel-list{user-select:none;position:relative;top:0;left:0;display:block;overflow:hidden}.ab-carousel-slider{outline:0;overflow:hidden;float:left;display:none}.ab-carousel.ab-carousel-init .ab-carousel-slider{display:block}
1
+ .ab-carousel{position:relative;height:100%}.ab-carousel-content{position:relative;display:block;height:100%;width:100%;margin:0;padding:0;overflow:hidden}.ab-carousel-list{user-select:none;position:relative;top:0;left:0;display:block;overflow:hidden}.ab-carousel-slider{outline:0;overflow:hidden;display:none}.ab-carousel.ab-carousel-init .ab-carousel-slider{display:block}.ab-carousel.ab-carousel-hr .ab-carousel-slider{float:left}