pixuireactcomponents 1.3.26 → 1.3.27

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.
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { Carousel } from "./src/components/react/app/carousel/Carousel";
2
2
  export { Button } from "./src/components/react/app/button/Button";
3
- export { Checkbox } from "./src/components/react/app/checkBox/CheckBox";
4
3
  export { Dropdown } from "./src/components/react/app/dropdown/Dropdown";
5
4
  export { ImageViewer } from "./src/components/react/app/imageViewer/imageViewer";
6
5
  export { ToggleGroup } from "./src/components/react/app/togglegroup/ToggleGroup";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixuireactcomponents",
3
- "version": "1.3.26",
3
+ "version": "1.3.27",
4
4
  "description": "pixui react components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,6 +6,8 @@ interface ButtonProps {
6
6
  hoverStyle: JCSSProperties;
7
7
  pressStyle: JCSSProperties;
8
8
  clickEvent: Function;
9
+ id: string;
10
+ className: string;
9
11
  }
10
12
  export declare let Button: (props: ButtonProps) => h.JSX.Element;
11
13
  export {};
@@ -9,11 +9,7 @@ var ButtonState;
9
9
  export var Button = function (props) {
10
10
  var _a;
11
11
  var buttonState = (_a = useState(ButtonState.normal), _a[0]), setButtonState = _a[1];
12
- return (h("div", { style: buttonState == ButtonState.normal
13
- ? props.normalStyle
14
- : buttonState == ButtonState.hover
15
- ? props.hoverStyle
16
- : props.pressStyle, onMouseDown: function () {
12
+ return (h("div", { style: buttonState == ButtonState.normal ? props.normalStyle : buttonState == ButtonState.hover ? props.hoverStyle : props.pressStyle, onMouseDown: function () {
17
13
  setButtonState(ButtonState.press);
18
14
  }, onMouseUp: function () {
19
15
  setButtonState(ButtonState.hover);
@@ -22,5 +18,5 @@ export var Button = function (props) {
22
18
  setButtonState(ButtonState.hover);
23
19
  }, onMouseOut: function () {
24
20
  setButtonState(ButtonState.normal);
25
- } }, props.text));
21
+ }, id: props.id, className: props.className }, props.text));
26
22
  };
@@ -12,9 +12,11 @@ import { h } from 'preact';
12
12
  * @param isVertical - 轮播元素滚动方向
13
13
  * @param touchable - 是否允许手势切换
14
14
  * @param onSlideChange - 切换元素后的回调函数
15
- * @param onclickEvent - 点击元素的回调函数
15
+ * @param onClick - 点击元素的回调函数
16
16
  */
17
17
  export declare function Carousel(props: {
18
+ id?: string;
19
+ className?: string;
18
20
  cRef?: any;
19
21
  children?: preact.JSX.Element[] | HTMLElement[];
20
22
  defaultIndex?: number;
@@ -26,5 +28,5 @@ export declare function Carousel(props: {
26
28
  isVertical?: boolean;
27
29
  touchable?: boolean;
28
30
  onSlideChange?: Function | null;
29
- onclickEvent?: Function | null;
31
+ onClick?: Function | null;
30
32
  }): h.JSX.Element;
@@ -19,7 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
21
  import { h } from 'preact';
22
- import { useState, useEffect, useRef, useMemo, useImperativeHandle } from '../../../../../lib/preact/hooks/src';
22
+ import { useImperativeHandle, useState, useRef, useMemo, useEffect } from 'preact/hooks';
23
23
  // import { memo } from '../../../../../lib/preact/compat/src';
24
24
  //组件优化,防止组件的props没有改变但父组件刷新时导致组件刷新
25
25
  // export let Carousel = memo(Carouselinner, (prev, next) => {
@@ -58,29 +58,48 @@ import { useState, useEffect, useRef, useMemo, useImperativeHandle } from '../..
58
58
  * @param isVertical - 轮播元素滚动方向
59
59
  * @param touchable - 是否允许手势切换
60
60
  * @param onSlideChange - 切换元素后的回调函数
61
- * @param onclickEvent - 点击元素的回调函数
61
+ * @param onClick - 点击元素的回调函数
62
62
  */
63
63
  export function Carousel(props) {
64
- var _a = props.children, children = _a === void 0 ? [] : _a, _b = props.defaultIndex, defaultIndex = _b === void 0 ? 1 : _b, _c = props.compWidth, compWidth = _c === void 0 ? 100 : _c, _d = props.compHeight, compHeight = _d === void 0 ? 100 : _d, _e = props.autoplay, autoplay = _e === void 0 ? true : _e, _f = props.switchDuration, switchDuration = _f === void 0 ? 3000 : _f, _g = props.loop, loop = _g === void 0 ? true : _g, _h = props.isVertical, isVertical = _h === void 0 ? false : _h, _j = props.touchable, touchable = _j === void 0 ? true : _j, _k = props.onSlideChange, onSlideChange = _k === void 0 ? null : _k, _l = props.onclickEvent, onclickEvent = _l === void 0 ? null : _l;
64
+ var _a = props.id, id = _a === void 0 ? '' : _a, _b = props.className, className = _b === void 0 ? '' : _b, _c = props.children, children = _c === void 0 ? [] : _c, _d = props.defaultIndex, defaultIndex = _d === void 0 ? 1 : _d, _e = props.compWidth, compWidth = _e === void 0 ? 100 : _e, _f = props.compHeight, compHeight = _f === void 0 ? 100 : _f, _g = props.autoplay, autoplay = _g === void 0 ? true : _g, _h = props.switchDuration, switchDuration = _h === void 0 ? 3000 : _h, _j = props.loop, loop = _j === void 0 ? true : _j, _k = props.isVertical, isVertical = _k === void 0 ? false : _k, _l = props.touchable, touchable = _l === void 0 ? true : _l, _m = props.onSlideChange, onSlideChange = _m === void 0 ? null : _m, _o = props.onClick, onClick = _o === void 0 ? null : _o;
65
65
  // console.log('children', children.length);
66
+ var safeNext = function () {
67
+ if (!canClickSwitch.current)
68
+ return;
69
+ canClickSwitch.current = false;
70
+ setTimeout(function () {
71
+ canClickSwitch.current = true;
72
+ }, 1000);
73
+ handleNext();
74
+ };
75
+ var safePrev = function () {
76
+ if (!canClickSwitch.current)
77
+ return;
78
+ canClickSwitch.current = false;
79
+ setTimeout(function () {
80
+ canClickSwitch.current = true;
81
+ }, 1000);
82
+ handlePrev();
83
+ };
66
84
  useImperativeHandle(props.cRef, function () { return ({
67
- handleNext: handleNext,
68
- handlePrev: handlePrev,
85
+ handleNext: safeNext,
86
+ handlePrev: safePrev,
69
87
  setShowIndex: setShowIndex,
70
88
  }); });
71
89
  var duration = switchDuration < 1000 ? 1000 : switchDuration;
72
- var _m = useState(defaultIndex), showIndex = _m[0], setShowIndex = _m[1];
90
+ var _p = useState(defaultIndex), showIndex = _p[0], setShowIndex = _p[1];
73
91
  //轮播元素正在滚动
74
92
  var isMoving = useRef(false);
75
93
  //鼠标手势信息
76
94
  var isMouseDown = useRef(false);
77
95
  var mouseDownX = useRef(0);
78
96
  var mouseDownY = useRef(0);
97
+ //pixui在 onTransitionEnd 之后马上触发 transform 会丢onTransitionEnd
98
+ var canClickSwitch = useRef(true);
79
99
  var handleNextRef = useRef(function () { });
80
100
  var nextInterval = useRef();
81
- var _o = useState(true), showTransition = _o[0], setShowTransition = _o[1];
82
- var _p = useState([0, 0]), gesteroffset = _p[0], setGesteroffset = _p[1];
83
- var _q = useState(''), logTex = _q[0], setLogTex = _q[1];
101
+ var _q = useState(true), showTransition = _q[0], setShowTransition = _q[1];
102
+ var _r = useState([0, 0]), gesteroffset = _r[0], setGesteroffset = _r[1];
84
103
  var offset = useMemo(function () { return -(isVertical ? compHeight : compWidth) * showIndex; }, [showIndex]);
85
104
  var itemBoxStyle = {
86
105
  minWidth: compWidth + 'px',
@@ -136,7 +155,6 @@ export function Carousel(props) {
136
155
  }
137
156
  };
138
157
  var handleNext = function () {
139
- // console.log('nex', isMoving.current, showIndex, isVertical ? `translate(0px, ${offset}px)` : `translate(${offset}px, 0px)`)
140
158
  if (!loop && showIndex == carouselItems.length - 2)
141
159
  return;
142
160
  if (isMoving.current)
@@ -228,11 +246,11 @@ export function Carousel(props) {
228
246
  var gestureClick = function (props) {
229
247
  if (isMoving.current)
230
248
  return;
231
- if (onclickEvent) {
232
- onclickEvent(showIndex - 1);
249
+ if (onClick) {
250
+ onClick(showIndex - 1);
233
251
  }
234
252
  };
235
- return (h("div", { style: { flexDirection: 'column' } },
253
+ return (h("div", { style: { flexDirection: 'column', width: compWidth, height: compHeight }, id: id, className: className },
236
254
  h("div", { draggable: true, style: __assign(__assign({}, itemBoxStyle), { position: 'absolute' }), onClick: function (ev) {
237
255
  gestureClick(props);
238
256
  }, class: 'GestureComp', onDragStart: function (e) {
@@ -254,9 +272,7 @@ export function Carousel(props) {
254
272
  width: isVertical ? compWidth : compWidth * carouselItems.length + 'px',
255
273
  height: isVertical ? compHeight * carouselItems.length : compHeight + 'px',
256
274
  transition: "transform ".concat(showTransition ? '0.5s' : '0s', " ease 0s"),
257
- transform: isVertical
258
- ? "translate(0px, ".concat(offset + gesteroffset[1], "px)")
259
- : "translate(".concat(offset + gesteroffset[0], "px, 0px)"),
275
+ transform: isVertical ? "translate(0px, ".concat(offset + gesteroffset[1], "px)") : "translate(".concat(offset + gesteroffset[0], "px, 0px)"),
260
276
  flexDirection: isVertical ? 'column' : 'row',
261
277
  flexShrink: 0,
262
278
  }, class: "wrapper", onTransitionEnd: handleTransitionEnd }, carouselItems.map(function (child) { return child; }))))));
@@ -1,7 +1,10 @@
1
1
  import { h } from 'preact';
2
- export declare function Checkbox(props: {
3
- selectedChanged: Function | null;
4
- defauleSelected: boolean;
5
- selectedNode: any;
6
- notSelectedNode: any;
2
+ export declare function CheckBox(props: {
3
+ id?: string;
4
+ className?: string;
5
+ selectedChanged?: Function;
6
+ defauleSelected?: boolean;
7
+ selectedNode?: any;
8
+ notSelectedNode?: any;
9
+ toggleSize?: number;
7
10
  }): h.JSX.Element;
@@ -1,13 +1,12 @@
1
1
  import { h } from 'preact';
2
- import { useState } from '../../../../../lib/preact/hooks/src';
3
- export function Checkbox(props) {
4
- var _a = props.selectedChanged, selectedChanged = _a === void 0 ? null : _a, _b = props.defauleSelected, defauleSelected = _b === void 0 ? false : _b, _c = props.selectedNode, selectedNode = _c === void 0 ? null : _c, _d = props.notSelectedNode, notSelectedNode = _d === void 0 ? null : _d;
5
- var _e = useState(defauleSelected), selected = _e[0], setSelected = _e[1];
6
- var cli = function () {
7
- if (selectedChanged) {
8
- selectedChanged(!selected);
9
- }
10
- setSelected(!selected);
11
- };
12
- return h("div", { onClick: cli }, selected ? selectedNode : notSelectedNode);
2
+ import { useState } from 'preact/hooks';
3
+ export function CheckBox(props) {
4
+ var _a = props.id, id = _a === void 0 ? '' : _a, _b = props.className, className = _b === void 0 ? '' : _b, _c = props.selectedChanged, selectedChanged = _c === void 0 ? null : _c, _d = props.defauleSelected, defauleSelected = _d === void 0 ? false : _d, _e = props.toggleSize, toggleSize = _e === void 0 ? 20 : _e;
5
+ var _f = useState(defauleSelected), selected = _f[0], setSelected = _f[1];
6
+ props.selectedNode = props.selectedNode || (h("img", { src: "https://game.gtimg.cn/images/gamelet/cp/pixui-jnResources/check-box.png", style: { width: toggleSize + 'px', height: toggleSize + 'px' } }));
7
+ props.notSelectedNode = props.notSelectedNode || (h("img", { src: "https://game.gtimg.cn/images/gamelet/cp/pixui-jnResources/blank-check-box.png", style: { width: toggleSize + 'px', height: toggleSize + 'px' } }));
8
+ return (h("div", { onClick: function () {
9
+ selectedChanged && selectedChanged(!selected);
10
+ setSelected(!selected);
11
+ }, id: id, className: className }, selected ? props.selectedNode : props.notSelectedNode));
13
12
  }
@@ -1,5 +1,7 @@
1
1
  import { Component, CSSProperties, h } from 'preact';
2
2
  export interface SliderProps {
3
+ id?: string;
4
+ className?: string;
3
5
  percent?: number;
4
6
  wrapperWidth?: number;
5
7
  wrapperHeight?: number;
@@ -40,13 +40,13 @@ var rowCenterCenter = {
40
40
  display: 'flex',
41
41
  flexDirection: 'row',
42
42
  justifyContent: 'center',
43
- alignItems: 'center'
43
+ alignItems: 'center',
44
44
  };
45
45
  var rowBetweenCenter = {
46
46
  display: 'flex',
47
47
  flexDirection: 'row',
48
48
  justifyContent: 'space-between',
49
- alignItems: 'center'
49
+ alignItems: 'center',
50
50
  };
51
51
  export var Slider = /** @class */ (function (_super) {
52
52
  __extends(Slider, _super);
@@ -60,9 +60,14 @@ export var Slider = /** @class */ (function (_super) {
60
60
  //====================================================================================================
61
61
  //事件相关
62
62
  _this.onDragStart = function (event) {
63
- console.log('【Slider】DragStart event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
63
+ console.log('【Slider】DragStart event.clientX--' +
64
+ event.clientX +
65
+ '-----percent----' +
66
+ _this.state.percent +
67
+ '-----currentX----' +
68
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
64
69
  _this.lastX = event.clentX;
65
- _this.count = _this.state.percent / 10000 * _this.props.wrapperWidth;
70
+ _this.count = (_this.state.percent / 10000) * _this.props.wrapperWidth;
66
71
  _this.setState({
67
72
  onDraging: true,
68
73
  });
@@ -71,19 +76,41 @@ export var Slider = /** @class */ (function (_super) {
71
76
  }
72
77
  };
73
78
  _this.onDrag = function (event) {
79
+ console.log('【Slider】onDrag0 event.clientX--' +
80
+ event.clientX +
81
+ '-----percent----' +
82
+ _this.state.percent +
83
+ '-----currentX----' +
84
+ (_this.state.percent / 10000) * _this.props.wrapperWidth +
85
+ 'rect.left' +
86
+ _this.rect.left +
87
+ 'rect.right' +
88
+ _this.rect.right);
74
89
  if (event.clientX < _this.rect.left - 50 || event.clientX > _this.rect.right + 50)
75
90
  return;
91
+ console.log('【Slider】onDrag1 event.clientX--' +
92
+ event.clientX +
93
+ '-----percent----' +
94
+ _this.state.percent +
95
+ '-----currentX----' +
96
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
76
97
  if (_this.lastX == undefined) {
77
98
  _this.lastX = event.clientX;
78
99
  return;
79
100
  }
101
+ console.log('【Slider】onDrag2 event.clientX--' +
102
+ event.clientX +
103
+ '-----percent----' +
104
+ _this.state.percent +
105
+ '-----currentX----' +
106
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
80
107
  var move = Number(event.clientX) - Number(_this.lastX);
81
108
  _this.count += move;
82
109
  _this.count = Math.min(_this.props.wrapperWidth, _this.count);
83
110
  _this.count = Math.max(0, _this.count);
84
- var newPercent = _this.count / _this.props.wrapperWidth * 10000;
111
+ var newPercent = (_this.count / _this.props.wrapperWidth) * 10000;
85
112
  if (_this.props.isDiscrete == true) {
86
- newPercent = _this.count / _this.props.wrapperWidth * _this.props.maxDiscrete;
113
+ newPercent = (_this.count / _this.props.wrapperWidth) * _this.props.maxDiscrete;
87
114
  _this.discrete = Math.round(newPercent);
88
115
  if (_this.props.rangeControl) {
89
116
  _this.discrete = Math.min(_this.discrete, _this.props.endRange);
@@ -92,9 +119,16 @@ export var Slider = /** @class */ (function (_super) {
92
119
  newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
93
120
  }
94
121
  _this.setState({
95
- percent: newPercent
122
+ percent: newPercent,
96
123
  }, function () {
97
- console.log('【Slider】OnDrag event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----discrete----' + _this.discrete + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
124
+ console.log('【Slider】OnDrag event.clientX--' +
125
+ event.clientX +
126
+ '-----percent----' +
127
+ _this.state.percent +
128
+ '-----discrete----' +
129
+ _this.discrete +
130
+ '-----currentX----' +
131
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
98
132
  if (_this.props.onDrag)
99
133
  _this.props.onDrag(_this.props.isDiscrete ? _this.discrete : newPercent);
100
134
  });
@@ -106,19 +140,31 @@ export var Slider = /** @class */ (function (_super) {
106
140
  //console.log("OnDragEnd -----discrete----"+this.state.discrete)
107
141
  _this.setState({
108
142
  percent: _this.discrete * (10000 / _this.props.maxDiscrete),
109
- onDraging: false
143
+ onDraging: false,
110
144
  }, function () {
111
- console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----discrete----' + _this.discrete + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
145
+ console.log('【Slider】DragEnd event.clientX--' +
146
+ event.clientX +
147
+ '-----percent----' +
148
+ _this.state.percent +
149
+ '-----discrete----' +
150
+ _this.discrete +
151
+ '-----currentX----' +
152
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
112
153
  if (_this.props.onDragEnd) {
113
154
  _this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
114
155
  }
115
156
  });
116
157
  }
117
158
  else {
118
- console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
159
+ console.log('【Slider】DragEnd event.clientX--' +
160
+ event.clientX +
161
+ '-----percent----' +
162
+ _this.state.percent +
163
+ '-----currentX----' +
164
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
119
165
  _this.setState({
120
- percent: _this.count / _this.props.wrapperWidth * 10000,
121
- onDraging: false
166
+ percent: (_this.count / _this.props.wrapperWidth) * 10000,
167
+ onDraging: false,
122
168
  }, function () {
123
169
  if (_this.props.onDragEnd) {
124
170
  _this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
@@ -136,7 +182,7 @@ export var Slider = /** @class */ (function (_super) {
136
182
  }
137
183
  var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
138
184
  _this.setState({
139
- percent: newPercent
185
+ percent: newPercent,
140
186
  }, function () {
141
187
  if (_this.props.onDecClick) {
142
188
  _this.props.onDecClick(_this.discrete);
@@ -148,7 +194,7 @@ export var Slider = /** @class */ (function (_super) {
148
194
  else {
149
195
  if (_this.state.percent > 0) {
150
196
  _this.setState({
151
- percent: _this.state.percent - 1
197
+ percent: _this.state.percent - 1,
152
198
  }, function () {
153
199
  if (_this.props.onDecClick) {
154
200
  _this.props.onDecClick(_this.state.percent);
@@ -168,7 +214,7 @@ export var Slider = /** @class */ (function (_super) {
168
214
  var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
169
215
  _this.setState({
170
216
  // discrete: this.state.discrete + 1,
171
- percent: newPercent
217
+ percent: newPercent,
172
218
  }, function () {
173
219
  if (_this.props.onIncClick) {
174
220
  _this.props.onIncClick(_this.discrete);
@@ -180,7 +226,7 @@ export var Slider = /** @class */ (function (_super) {
180
226
  else {
181
227
  if (_this.state.percent < 10000) {
182
228
  _this.setState({
183
- percent: _this.state.percent + 1
229
+ percent: _this.state.percent + 1,
184
230
  }, function () {
185
231
  if (_this.props.onIncClick) {
186
232
  _this.props.onIncClick(_this.state.percent);
@@ -204,27 +250,25 @@ export var Slider = /** @class */ (function (_super) {
204
250
  display: 'flex',
205
251
  flexDirection: 'row',
206
252
  justifyContent: 'start',
207
- alignItems: 'center'
253
+ alignItems: 'center',
208
254
  };
209
255
  return outerStyle;
210
256
  };
211
257
  _this.innerStyle = function () {
212
258
  var innerStyle = {
213
259
  // width: innerWidth,
214
- height: (_this.props.innerHeight != null) ? _this.props.innerHeight + 'px' : '100%',
260
+ height: _this.props.innerHeight != null ? _this.props.innerHeight + 'px' : '100%',
215
261
  backgroundImage: "url(".concat(_this.props.innerBg, ")"),
216
262
  backgroundSize: '100% 100%',
217
263
  display: 'flex',
218
264
  flexDirection: 'row',
219
265
  justifyContent: 'start',
220
- alignItems: 'center'
266
+ alignItems: 'center',
221
267
  };
222
268
  return innerStyle;
223
269
  };
224
270
  _this.dotWrapperStyle = function () {
225
- var dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px' }, rowCenterCenter
226
- // backgroundColor: '#FF000066'
227
- );
271
+ var dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px' }, rowCenterCenter);
228
272
  return dotWrapperStyle;
229
273
  };
230
274
  _this.dotStyle = function () {
@@ -282,8 +326,7 @@ export var Slider = /** @class */ (function (_super) {
282
326
  var _a = this.props, percent = _a.percent, discrete = _a.discrete, styleProps = __rest(_a, ["percent", "discrete"]);
283
327
  var nextPercent = nextProps.percent, nextDiscrete = nextProps.discrete, nextstyleProps = __rest(nextProps, ["percent", "discrete"]);
284
328
  //拖动状态时,忽略外部传入的percent值,优先用户拖动
285
- var shouldUpdatePercent = !(this.state.onDraging) &&
286
- !(percent == nextPercent && discrete == nextDiscrete);
329
+ var shouldUpdatePercent = !this.state.onDraging && !(percent == nextPercent && discrete == nextDiscrete);
287
330
  console.log('检查shouldUpdatePercent', shouldUpdatePercent);
288
331
  if (shouldUpdatePercent) {
289
332
  //如果从外部传入percent/discrete,则组件可根据新props来更新滑动条位置
@@ -291,7 +334,7 @@ export var Slider = /** @class */ (function (_super) {
291
334
  if (this.props.isDiscrete == true) {
292
335
  this.discrete = nextProps.discrete;
293
336
  this.setState({
294
- percent: this.discrete * (10000 / this.props.maxDiscrete)
337
+ percent: this.discrete * (10000 / this.props.maxDiscrete),
295
338
  });
296
339
  }
297
340
  //连续情况
@@ -318,8 +361,8 @@ export var Slider = /** @class */ (function (_super) {
318
361
  Slider.prototype.render = function () {
319
362
  var hasDot = this.props.hasDot === undefined || this.props.hasDot === true;
320
363
  var innerWidth = Math.floor(this.state.percent / 100) + '%';
321
- var dotWrapperMarginLeft = (this.props.wrapperWidth * this.state.percent / 10000 - this.props.dotWrapperWidth / 2) + 'px';
322
- return (h("div", { style: this.props.hasIncDecButton ? this.state.withButtonStyle : {} },
364
+ var dotWrapperMarginLeft = (this.props.wrapperWidth * this.state.percent) / 10000 - this.props.dotWrapperWidth / 2 + 'px';
365
+ return (h("div", { style: this.props.hasIncDecButton ? this.state.withButtonStyle : {}, id: this.props.id, className: this.props.className },
323
366
  this.props.hasIncDecButton && h("img", { src: this.props.decButtonBg, style: this.state.decButtonStyle, onClick: this.onDecClick }),
324
367
  h("div", { ref: this.refWrapper, style: this.state.wrapperStyle },
325
368
  h("div", { style: this.state.outerStyle },