pixuireactcomponents 1.3.26 → 1.3.28

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.28",
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,42 @@ export var Slider = /** @class */ (function (_super) {
71
76
  }
72
77
  };
73
78
  _this.onDrag = function (event) {
74
- if (event.clientX < _this.rect.left - 50 || event.clientX > _this.rect.right + 50)
75
- return;
79
+ // console.log(
80
+ // '【Slider】onDrag0 event.clientX--' +
81
+ // event.clientX +
82
+ // '-----percent----' +
83
+ // this.state.percent +
84
+ // '-----currentX----' +
85
+ // (this.state.percent / 10000) * this.props.wrapperWidth! +
86
+ // 'rect.left' +
87
+ // this.rect.left +
88
+ // 'rect.right' +
89
+ // this.rect.right
90
+ // );
91
+ // if (event.clientX < this.rect.left - 50 || event.clientX > this.rect.right + 50) return;
92
+ console.log('【Slider】onDrag1 event.clientX--' +
93
+ event.clientX +
94
+ '-----percent----' +
95
+ _this.state.percent +
96
+ '-----currentX----' +
97
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
76
98
  if (_this.lastX == undefined) {
77
99
  _this.lastX = event.clientX;
78
100
  return;
79
101
  }
102
+ console.log('【Slider】onDrag2 event.clientX--' +
103
+ event.clientX +
104
+ '-----percent----' +
105
+ _this.state.percent +
106
+ '-----currentX----' +
107
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
80
108
  var move = Number(event.clientX) - Number(_this.lastX);
81
109
  _this.count += move;
82
110
  _this.count = Math.min(_this.props.wrapperWidth, _this.count);
83
111
  _this.count = Math.max(0, _this.count);
84
- var newPercent = _this.count / _this.props.wrapperWidth * 10000;
112
+ var newPercent = (_this.count / _this.props.wrapperWidth) * 10000;
85
113
  if (_this.props.isDiscrete == true) {
86
- newPercent = _this.count / _this.props.wrapperWidth * _this.props.maxDiscrete;
114
+ newPercent = (_this.count / _this.props.wrapperWidth) * _this.props.maxDiscrete;
87
115
  _this.discrete = Math.round(newPercent);
88
116
  if (_this.props.rangeControl) {
89
117
  _this.discrete = Math.min(_this.discrete, _this.props.endRange);
@@ -92,9 +120,16 @@ export var Slider = /** @class */ (function (_super) {
92
120
  newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
93
121
  }
94
122
  _this.setState({
95
- percent: newPercent
123
+ percent: newPercent,
96
124
  }, 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));
125
+ console.log('【Slider】OnDrag event.clientX--' +
126
+ event.clientX +
127
+ '-----percent----' +
128
+ _this.state.percent +
129
+ '-----discrete----' +
130
+ _this.discrete +
131
+ '-----currentX----' +
132
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
98
133
  if (_this.props.onDrag)
99
134
  _this.props.onDrag(_this.props.isDiscrete ? _this.discrete : newPercent);
100
135
  });
@@ -106,19 +141,31 @@ export var Slider = /** @class */ (function (_super) {
106
141
  //console.log("OnDragEnd -----discrete----"+this.state.discrete)
107
142
  _this.setState({
108
143
  percent: _this.discrete * (10000 / _this.props.maxDiscrete),
109
- onDraging: false
144
+ onDraging: false,
110
145
  }, 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));
146
+ console.log('【Slider】DragEnd event.clientX--' +
147
+ event.clientX +
148
+ '-----percent----' +
149
+ _this.state.percent +
150
+ '-----discrete----' +
151
+ _this.discrete +
152
+ '-----currentX----' +
153
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
112
154
  if (_this.props.onDragEnd) {
113
155
  _this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
114
156
  }
115
157
  });
116
158
  }
117
159
  else {
118
- console.log('【Slider】DragEnd event.clientX--' + event.clientX + '-----percent----' + _this.state.percent + '-----currentX----' + (_this.state.percent / 10000 * _this.props.wrapperWidth));
160
+ console.log('【Slider】DragEnd event.clientX--' +
161
+ event.clientX +
162
+ '-----percent----' +
163
+ _this.state.percent +
164
+ '-----currentX----' +
165
+ (_this.state.percent / 10000) * _this.props.wrapperWidth);
119
166
  _this.setState({
120
- percent: _this.count / _this.props.wrapperWidth * 10000,
121
- onDraging: false
167
+ percent: (_this.count / _this.props.wrapperWidth) * 10000,
168
+ onDraging: false,
122
169
  }, function () {
123
170
  if (_this.props.onDragEnd) {
124
171
  _this.props.onDragEnd(_this.props.isDiscrete ? _this.discrete : _this.state.percent);
@@ -136,7 +183,7 @@ export var Slider = /** @class */ (function (_super) {
136
183
  }
137
184
  var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
138
185
  _this.setState({
139
- percent: newPercent
186
+ percent: newPercent,
140
187
  }, function () {
141
188
  if (_this.props.onDecClick) {
142
189
  _this.props.onDecClick(_this.discrete);
@@ -148,7 +195,7 @@ export var Slider = /** @class */ (function (_super) {
148
195
  else {
149
196
  if (_this.state.percent > 0) {
150
197
  _this.setState({
151
- percent: _this.state.percent - 1
198
+ percent: _this.state.percent - 1,
152
199
  }, function () {
153
200
  if (_this.props.onDecClick) {
154
201
  _this.props.onDecClick(_this.state.percent);
@@ -168,7 +215,7 @@ export var Slider = /** @class */ (function (_super) {
168
215
  var newPercent = _this.discrete * (10000 / _this.props.maxDiscrete);
169
216
  _this.setState({
170
217
  // discrete: this.state.discrete + 1,
171
- percent: newPercent
218
+ percent: newPercent,
172
219
  }, function () {
173
220
  if (_this.props.onIncClick) {
174
221
  _this.props.onIncClick(_this.discrete);
@@ -180,7 +227,7 @@ export var Slider = /** @class */ (function (_super) {
180
227
  else {
181
228
  if (_this.state.percent < 10000) {
182
229
  _this.setState({
183
- percent: _this.state.percent + 1
230
+ percent: _this.state.percent + 1,
184
231
  }, function () {
185
232
  if (_this.props.onIncClick) {
186
233
  _this.props.onIncClick(_this.state.percent);
@@ -204,27 +251,25 @@ export var Slider = /** @class */ (function (_super) {
204
251
  display: 'flex',
205
252
  flexDirection: 'row',
206
253
  justifyContent: 'start',
207
- alignItems: 'center'
254
+ alignItems: 'center',
208
255
  };
209
256
  return outerStyle;
210
257
  };
211
258
  _this.innerStyle = function () {
212
259
  var innerStyle = {
213
260
  // width: innerWidth,
214
- height: (_this.props.innerHeight != null) ? _this.props.innerHeight + 'px' : '100%',
261
+ height: _this.props.innerHeight != null ? _this.props.innerHeight + 'px' : '100%',
215
262
  backgroundImage: "url(".concat(_this.props.innerBg, ")"),
216
263
  backgroundSize: '100% 100%',
217
264
  display: 'flex',
218
265
  flexDirection: 'row',
219
266
  justifyContent: 'start',
220
- alignItems: 'center'
267
+ alignItems: 'center',
221
268
  };
222
269
  return innerStyle;
223
270
  };
224
271
  _this.dotWrapperStyle = function () {
225
- var dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px' }, rowCenterCenter
226
- // backgroundColor: '#FF000066'
227
- );
272
+ var dotWrapperStyle = __assign({ position: 'absolute', width: _this.props.dotWrapperWidth + 'px', height: _this.props.dotWrapperHeight + 'px' }, rowCenterCenter);
228
273
  return dotWrapperStyle;
229
274
  };
230
275
  _this.dotStyle = function () {
@@ -282,8 +327,7 @@ export var Slider = /** @class */ (function (_super) {
282
327
  var _a = this.props, percent = _a.percent, discrete = _a.discrete, styleProps = __rest(_a, ["percent", "discrete"]);
283
328
  var nextPercent = nextProps.percent, nextDiscrete = nextProps.discrete, nextstyleProps = __rest(nextProps, ["percent", "discrete"]);
284
329
  //拖动状态时,忽略外部传入的percent值,优先用户拖动
285
- var shouldUpdatePercent = !(this.state.onDraging) &&
286
- !(percent == nextPercent && discrete == nextDiscrete);
330
+ var shouldUpdatePercent = !this.state.onDraging && !(percent == nextPercent && discrete == nextDiscrete);
287
331
  console.log('检查shouldUpdatePercent', shouldUpdatePercent);
288
332
  if (shouldUpdatePercent) {
289
333
  //如果从外部传入percent/discrete,则组件可根据新props来更新滑动条位置
@@ -291,7 +335,7 @@ export var Slider = /** @class */ (function (_super) {
291
335
  if (this.props.isDiscrete == true) {
292
336
  this.discrete = nextProps.discrete;
293
337
  this.setState({
294
- percent: this.discrete * (10000 / this.props.maxDiscrete)
338
+ percent: this.discrete * (10000 / this.props.maxDiscrete),
295
339
  });
296
340
  }
297
341
  //连续情况
@@ -318,8 +362,8 @@ export var Slider = /** @class */ (function (_super) {
318
362
  Slider.prototype.render = function () {
319
363
  var hasDot = this.props.hasDot === undefined || this.props.hasDot === true;
320
364
  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 : {} },
365
+ var dotWrapperMarginLeft = (this.props.wrapperWidth * this.state.percent) / 10000 - this.props.dotWrapperWidth / 2 + 'px';
366
+ return (h("div", { style: this.props.hasIncDecButton ? this.state.withButtonStyle : {}, id: this.props.id, className: this.props.className },
323
367
  this.props.hasIncDecButton && h("img", { src: this.props.decButtonBg, style: this.state.decButtonStyle, onClick: this.onDecClick }),
324
368
  h("div", { ref: this.refWrapper, style: this.state.wrapperStyle },
325
369
  h("div", { style: this.state.outerStyle },