@ray-js/lamp-circle-picker 1.0.12-beta-1 → 1.0.12-beta-2
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/example/src/pages/index.tsx +25 -13
- package/lib/component/index.js +30 -6
- package/lib/component/props.d.ts +39 -3
- package/lib/component/rjs/index.js +59 -11
- package/lib/component/rjs/index.rjs +51 -11
- package/lib/component/rjs/index.tyml +3 -3
- package/lib/component/rjs/index.tyss +5 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +33 -20
- package/lib/index.module.less +1 -0
- package/lib/props.d.ts +16 -2
- package/package.json +1 -1
|
@@ -17,28 +17,34 @@ const DemoBlock = ({ title, children }) => (
|
|
|
17
17
|
export default function Home() {
|
|
18
18
|
const [temperature, setTemperature] = useState(20);
|
|
19
19
|
|
|
20
|
-
const handleMove = (v: number) => {
|
|
21
|
-
setTemperature(v);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
20
|
const handleEnd = (v: number) => {
|
|
25
21
|
setTemperature(v);
|
|
26
22
|
};
|
|
23
|
+
|
|
24
|
+
// useEffect(() => {
|
|
25
|
+
// setTimeout(() => {
|
|
26
|
+
// setTemperature(500);
|
|
27
|
+
// }, 4000);
|
|
28
|
+
// }, []);
|
|
29
|
+
|
|
30
|
+
const [inactive, setPowerOff] = useState(false);
|
|
27
31
|
useEffect(() => {
|
|
28
32
|
setTimeout(() => {
|
|
29
|
-
|
|
33
|
+
setPowerOff(true);
|
|
30
34
|
}, 3000);
|
|
31
35
|
}, []);
|
|
32
36
|
|
|
37
|
+
const [maskVisible, setShowMask] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
// setShowMask(true);
|
|
41
|
+
}, 2000);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
33
44
|
return (
|
|
34
45
|
<View className={styles.view}>
|
|
35
46
|
<DemoBlock title="基础用法">
|
|
36
|
-
<LampCirclePicker
|
|
37
|
-
value={temperature}
|
|
38
|
-
useEventChannel
|
|
39
|
-
onTouchMove={handleMove}
|
|
40
|
-
onTouchEnd={handleEnd}
|
|
41
|
-
/>
|
|
47
|
+
<LampCirclePicker value={temperature} useEventChannel onTouchEnd={handleEnd} />
|
|
42
48
|
</DemoBlock>
|
|
43
49
|
|
|
44
50
|
<DemoBlock title="HideThumb">
|
|
@@ -47,7 +53,14 @@ export default function Home() {
|
|
|
47
53
|
useEventChannel
|
|
48
54
|
hideThumb
|
|
49
55
|
lineCap="butt"
|
|
50
|
-
|
|
56
|
+
onTouchEnd={handleEnd}
|
|
57
|
+
/>
|
|
58
|
+
</DemoBlock>
|
|
59
|
+
<DemoBlock title="Inactive and maskVisible">
|
|
60
|
+
<LampCirclePicker
|
|
61
|
+
value={temperature}
|
|
62
|
+
inactive={inactive}
|
|
63
|
+
maskVisible={maskVisible}
|
|
51
64
|
onTouchEnd={handleEnd}
|
|
52
65
|
/>
|
|
53
66
|
</DemoBlock>
|
|
@@ -76,7 +89,6 @@ export default function Home() {
|
|
|
76
89
|
color: 'blue',
|
|
77
90
|
}}
|
|
78
91
|
useEventChannel
|
|
79
|
-
onTouchMove={handleMove}
|
|
80
92
|
onTouchEnd={handleEnd}
|
|
81
93
|
/>
|
|
82
94
|
</DemoBlock>
|
package/lib/component/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export default function RectColor(props) {
|
|
|
13
13
|
value: props.value,
|
|
14
14
|
hideThumb: (_props$hideThumb = props.hideThumb) !== null && _props$hideThumb !== void 0 ? _props$hideThumb : false,
|
|
15
15
|
canvasId: props.canvasId,
|
|
16
|
+
inactive: props.inactive,
|
|
17
|
+
maskVisible: props.maskVisible,
|
|
16
18
|
colorList: (_props$colorList = props.colorList) !== null && _props$colorList !== void 0 ? _props$colorList : [],
|
|
17
19
|
useEventChannel: props.useEventChannel,
|
|
18
20
|
lineCap: props.lineCap || 'round',
|
|
@@ -23,22 +25,44 @@ export default function RectColor(props) {
|
|
|
23
25
|
const {
|
|
24
26
|
detail
|
|
25
27
|
} = e;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
+
const {
|
|
29
|
+
rgb,
|
|
30
|
+
value
|
|
31
|
+
} = detail;
|
|
32
|
+
const temp = Math.floor(value);
|
|
33
|
+
props.onTouchStart && props.onTouchStart(temp, rgb);
|
|
28
34
|
},
|
|
29
35
|
bindmove: e => {
|
|
30
36
|
const {
|
|
31
37
|
detail
|
|
32
38
|
} = e;
|
|
33
|
-
const
|
|
34
|
-
|
|
39
|
+
const {
|
|
40
|
+
rgb,
|
|
41
|
+
value
|
|
42
|
+
} = detail;
|
|
43
|
+
const temp = Math.floor(value);
|
|
44
|
+
props.onTouchMove && props.onTouchMove(temp, rgb);
|
|
35
45
|
},
|
|
36
46
|
bindend: e => {
|
|
37
47
|
const {
|
|
38
48
|
detail
|
|
39
49
|
} = e;
|
|
40
|
-
const
|
|
41
|
-
|
|
50
|
+
const {
|
|
51
|
+
rgb,
|
|
52
|
+
value
|
|
53
|
+
} = detail;
|
|
54
|
+
const temp = Math.floor(value);
|
|
55
|
+
props.onTouchEnd && props.onTouchEnd(temp, rgb);
|
|
56
|
+
},
|
|
57
|
+
bindinit: e => {
|
|
58
|
+
const {
|
|
59
|
+
detail
|
|
60
|
+
} = e;
|
|
61
|
+
const {
|
|
62
|
+
rgb,
|
|
63
|
+
value
|
|
64
|
+
} = detail;
|
|
65
|
+
props.onInit && props.onInit(value, rgb);
|
|
42
66
|
}
|
|
43
67
|
});
|
|
44
68
|
}
|
package/lib/component/props.d.ts
CHANGED
|
@@ -49,6 +49,20 @@ export interface IProps {
|
|
|
49
49
|
offset: number;
|
|
50
50
|
color: string;
|
|
51
51
|
}[];
|
|
52
|
+
/**
|
|
53
|
+
* @description.zh 关闭状态
|
|
54
|
+
* @description.en inactive
|
|
55
|
+
* @default false
|
|
56
|
+
* @version 1.1.0
|
|
57
|
+
*/
|
|
58
|
+
inactive?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @description.zh 是否显示遮罩
|
|
61
|
+
* @description.en maskVisible
|
|
62
|
+
* @default false
|
|
63
|
+
* @version 1.1.0
|
|
64
|
+
*/
|
|
65
|
+
maskVisible?: boolean;
|
|
52
66
|
/**
|
|
53
67
|
* @description.zh 事件通道名称
|
|
54
68
|
* @description.en Event channel name
|
|
@@ -60,19 +74,41 @@ export interface IProps {
|
|
|
60
74
|
* @description.en Finger press when the callback function
|
|
61
75
|
* @default ''
|
|
62
76
|
*/
|
|
63
|
-
onTouchStart?: (value: number
|
|
77
|
+
onTouchStart?: (value: number, rgb: {
|
|
78
|
+
r: number;
|
|
79
|
+
g: number;
|
|
80
|
+
b: number;
|
|
81
|
+
}) => void;
|
|
64
82
|
/**
|
|
65
83
|
* @description.zh 手指按下拖动时的回调函数
|
|
66
84
|
* @description.en Finger to press the drag of the callback function
|
|
67
85
|
* @default ''
|
|
68
86
|
*/
|
|
69
|
-
onTouchMove?: (value: number
|
|
87
|
+
onTouchMove?: (value: number, rgb: {
|
|
88
|
+
r: number;
|
|
89
|
+
g: number;
|
|
90
|
+
b: number;
|
|
91
|
+
}) => void;
|
|
70
92
|
/**
|
|
71
93
|
* @description.zh 手指按下结束时的回调函数
|
|
72
94
|
* @description.en Finger press at the end of the callback function
|
|
73
95
|
* @default ''
|
|
74
96
|
*/
|
|
75
|
-
onTouchEnd?: (value: number
|
|
97
|
+
onTouchEnd?: (value: number, rgb: {
|
|
98
|
+
r: number;
|
|
99
|
+
g: number;
|
|
100
|
+
b: number;
|
|
101
|
+
}) => void;
|
|
102
|
+
/**
|
|
103
|
+
* @description.zh 初始化时的回调函数
|
|
104
|
+
* @description.en Initialization when the callback function
|
|
105
|
+
* @default ''
|
|
106
|
+
*/
|
|
107
|
+
onInit?: (value: number, rgb: {
|
|
108
|
+
r: number;
|
|
109
|
+
g: number;
|
|
110
|
+
b: number;
|
|
111
|
+
}) => void;
|
|
76
112
|
/**
|
|
77
113
|
* @description.en touchCircleStrokeStyle
|
|
78
114
|
* @description.zh 触摸圆环描边颜色
|
|
@@ -32,6 +32,16 @@ Component({
|
|
|
32
32
|
type: Number,
|
|
33
33
|
value: 0
|
|
34
34
|
},
|
|
35
|
+
// 是否显示遮罩
|
|
36
|
+
maskVisible: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
value: false
|
|
39
|
+
},
|
|
40
|
+
// 关闭状态
|
|
41
|
+
inactive: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
value: false
|
|
44
|
+
},
|
|
35
45
|
// 是否启用事件通道
|
|
36
46
|
useEventChannel: {
|
|
37
47
|
type: Boolean,
|
|
@@ -56,7 +66,9 @@ Component({
|
|
|
56
66
|
isTouch: false,
|
|
57
67
|
touchType: '',
|
|
58
68
|
colorText: '',
|
|
59
|
-
tipRectPosition: ETipRectPosition.LEFT
|
|
69
|
+
tipRectPosition: ETipRectPosition.LEFT,
|
|
70
|
+
prePowerOff: false,
|
|
71
|
+
preShowMask: false
|
|
60
72
|
},
|
|
61
73
|
observers: {
|
|
62
74
|
'value.**'(v) {
|
|
@@ -67,6 +79,28 @@ Component({
|
|
|
67
79
|
this._updatePosByRgb(v);
|
|
68
80
|
this.lastValue = v;
|
|
69
81
|
}
|
|
82
|
+
},
|
|
83
|
+
inactive(v) {
|
|
84
|
+
var _this$render, _this$render2;
|
|
85
|
+
if (this.prePowerOff === v) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
(_this$render = this.render) === null || _this$render === void 0 || _this$render.updateOptions({
|
|
89
|
+
inactive: v
|
|
90
|
+
});
|
|
91
|
+
this.prePowerOff = v;
|
|
92
|
+
(_this$render2 = this.render) === null || _this$render2 === void 0 || _this$render2.updateThumbPosition(null, null, null);
|
|
93
|
+
},
|
|
94
|
+
maskVisible(v) {
|
|
95
|
+
var _this$render3, _this$render4;
|
|
96
|
+
if (this.preShowMask === v) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.preShowMask = v;
|
|
100
|
+
(_this$render3 = this.render) === null || _this$render3 === void 0 || _this$render3.updateOptions({
|
|
101
|
+
maskVisible: v
|
|
102
|
+
});
|
|
103
|
+
(_this$render4 = this.render) === null || _this$render4 === void 0 || _this$render4.updateThumbPosition(null, null, null);
|
|
70
104
|
}
|
|
71
105
|
},
|
|
72
106
|
lifetimes: {
|
|
@@ -84,9 +118,9 @@ Component({
|
|
|
84
118
|
} = this.data;
|
|
85
119
|
this.initCanvas();
|
|
86
120
|
this.timer = setTimeout(() => {
|
|
87
|
-
var _this$
|
|
121
|
+
var _this$render5;
|
|
88
122
|
this.initCanvas();
|
|
89
|
-
(_this$
|
|
123
|
+
(_this$render5 = this.render) === null || _this$render5 === void 0 || _this$render5.checkIsRender(canvasId);
|
|
90
124
|
}, 300);
|
|
91
125
|
},
|
|
92
126
|
detached() {
|
|
@@ -112,8 +146,12 @@ Component({
|
|
|
112
146
|
colorList,
|
|
113
147
|
lineCap = 'round',
|
|
114
148
|
touchCircleStrokeStyle = '',
|
|
115
|
-
touchCircleLineWidth = 0
|
|
149
|
+
touchCircleLineWidth = 0,
|
|
150
|
+
inactive = false,
|
|
151
|
+
maskVisible = false
|
|
116
152
|
} = this.data;
|
|
153
|
+
this.prePowerOff = inactive;
|
|
154
|
+
this.preShowMask = maskVisible;
|
|
117
155
|
// 防止重复渲染
|
|
118
156
|
if (this.lastValue === value) {
|
|
119
157
|
return;
|
|
@@ -125,10 +163,16 @@ Component({
|
|
|
125
163
|
lineCap,
|
|
126
164
|
colorList,
|
|
127
165
|
touchCircleStrokeStyle,
|
|
128
|
-
touchCircleLineWidth
|
|
166
|
+
touchCircleLineWidth,
|
|
167
|
+
inactive,
|
|
168
|
+
maskVisible
|
|
129
169
|
});
|
|
130
170
|
this.lastValue = value;
|
|
131
171
|
},
|
|
172
|
+
updateOptions(options) {
|
|
173
|
+
var _this$render6, _this$render6$updateO;
|
|
174
|
+
(_this$render6 = this.render) === null || _this$render6 === void 0 || (_this$render6$updateO = _this$render6.updateOptions) === null || _this$render6$updateO === void 0 || _this$render6$updateO.call(_this$render6, options);
|
|
175
|
+
},
|
|
132
176
|
initedCanvas() {
|
|
133
177
|
const {
|
|
134
178
|
value
|
|
@@ -136,25 +180,29 @@ Component({
|
|
|
136
180
|
value !== undefined && this._updatePosByRgb(value);
|
|
137
181
|
},
|
|
138
182
|
_updatePosByRgb(value) {
|
|
139
|
-
var _this$
|
|
183
|
+
var _this$render7;
|
|
140
184
|
if (value === undefined) {
|
|
141
185
|
return;
|
|
142
186
|
}
|
|
143
|
-
(_this$
|
|
187
|
+
(_this$render7 = this.render) === null || _this$render7 === void 0 || _this$render7._getAnglePositionByValue(value);
|
|
144
188
|
},
|
|
145
189
|
_getRgb(x, y) {
|
|
146
|
-
var _this$
|
|
147
|
-
(_this$
|
|
190
|
+
var _this$render8;
|
|
191
|
+
(_this$render8 = this.render) === null || _this$render8 === void 0 || _this$render8.getAnnulusImageData(x, y);
|
|
148
192
|
},
|
|
149
193
|
_getAnnulusImageData(dataRes) {
|
|
150
194
|
const {
|
|
151
195
|
position,
|
|
152
|
-
touchType
|
|
196
|
+
touchType = 'init',
|
|
197
|
+
rgb
|
|
153
198
|
} = dataRes;
|
|
154
199
|
this.touchType = touchType;
|
|
155
200
|
const result = this._getLengthByAnglePosition(position.x, position.y);
|
|
156
201
|
this.lastValue = result;
|
|
157
|
-
this.triggerEvent(touchType,
|
|
202
|
+
this.triggerEvent(touchType, {
|
|
203
|
+
value: result,
|
|
204
|
+
rgb
|
|
205
|
+
});
|
|
158
206
|
},
|
|
159
207
|
_getLengthByAnglePosition(x, y) {
|
|
160
208
|
const {
|
|
@@ -53,7 +53,6 @@ export default Render({
|
|
|
53
53
|
return rgb ? { r: parseInt(rgb[1]), g: parseInt(rgb[2]), b: parseInt(rgb[3]) } : null;
|
|
54
54
|
},
|
|
55
55
|
|
|
56
|
-
|
|
57
56
|
getGradientColors(colorStops, steps) {
|
|
58
57
|
if (
|
|
59
58
|
!Array.isArray(colorStops) ||
|
|
@@ -265,9 +264,10 @@ export default Render({
|
|
|
265
264
|
// 环形色盘 降级绘制
|
|
266
265
|
async renderAnnulusColorLowRank(id, radius, innerRingRadius, options = {}) {
|
|
267
266
|
let canvas = null;
|
|
268
|
-
const { touchCircleStrokeStyle, ringBorderColor } =
|
|
269
|
-
options;
|
|
267
|
+
const { touchCircleStrokeStyle, ringBorderColor, inactive, maskVisible } = options;
|
|
270
268
|
this.touchCircleStrokeStyle = touchCircleStrokeStyle;
|
|
269
|
+
this.inactive = inactive;
|
|
270
|
+
this.maskVisible = maskVisible;
|
|
271
271
|
try {
|
|
272
272
|
canvas = await getCanvasById(id);
|
|
273
273
|
} catch (error) {
|
|
@@ -279,7 +279,6 @@ export default Render({
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
this.options = options || {};
|
|
283
282
|
this.radius = radius;
|
|
284
283
|
this.innerRingRadius = innerRingRadius;
|
|
285
284
|
|
|
@@ -300,8 +299,8 @@ export default Render({
|
|
|
300
299
|
const startDegree = 135;
|
|
301
300
|
const offsetDegree = 270;
|
|
302
301
|
const endDegree = startDegree + offsetDegree;
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
|
|
303
|
+
this.drawRingWithConicGradient({
|
|
305
304
|
startAngle: startDegree,
|
|
306
305
|
endAngle: endDegree,
|
|
307
306
|
offsetDegree,
|
|
@@ -324,11 +323,19 @@ export default Render({
|
|
|
324
323
|
// 环形色盘
|
|
325
324
|
async renderAnnulusColor(id, radius, innerRingRadius, temp = 0, options = {}) {
|
|
326
325
|
let canvas = null;
|
|
327
|
-
const {
|
|
326
|
+
const {
|
|
327
|
+
touchCircleStrokeStyle = '',
|
|
328
|
+
touchCircleLineWidth = 0,
|
|
329
|
+
hideThumb = false,
|
|
330
|
+
lineCap = 'round',
|
|
331
|
+
inactive = false,
|
|
332
|
+
maskVisible = false,
|
|
333
|
+
} = options || {};
|
|
328
334
|
this.touchCircleStrokeStyle = touchCircleStrokeStyle;
|
|
329
335
|
this.touchCircleLineWidth = touchCircleLineWidth;
|
|
330
336
|
this.hideThumb = hideThumb;
|
|
331
|
-
|
|
337
|
+
this.inactive = inactive;
|
|
338
|
+
this.maskVisible = maskVisible;
|
|
332
339
|
try {
|
|
333
340
|
canvas = await getCanvasById(id);
|
|
334
341
|
} catch (error) {
|
|
@@ -382,7 +389,7 @@ export default Render({
|
|
|
382
389
|
} catch (err) {
|
|
383
390
|
console.error('createConicGradient:', err);
|
|
384
391
|
}
|
|
385
|
-
|
|
392
|
+
!this.hideThumb && this.renderAnnulusColorThumb(id, temp);
|
|
386
393
|
this.callMethod('initedCanvas', {});
|
|
387
394
|
return;
|
|
388
395
|
}
|
|
@@ -393,6 +400,16 @@ export default Render({
|
|
|
393
400
|
!this.hideThumb && this.renderAnnulusColorThumb(id, temp);
|
|
394
401
|
this.callMethod('initedCanvas', {});
|
|
395
402
|
},
|
|
403
|
+
updateOptions(options) {
|
|
404
|
+
const { touchCircleStrokeStyle, touchCircleLineWidth, hideThumb, inactive, maskVisible } =
|
|
405
|
+
options || {};
|
|
406
|
+
|
|
407
|
+
this.touchCircleStrokeStyle = touchCircleStrokeStyle ?? this.touchCircleStrokeStyle;
|
|
408
|
+
this.touchCircleLineWidth = touchCircleLineWidth ?? this.touchCircleLineWidth;
|
|
409
|
+
this.hideThumb = hideThumb ?? this.hideThumb;
|
|
410
|
+
this.inactive = inactive ?? this.inactive;
|
|
411
|
+
this.maskVisible = maskVisible ?? this.maskVisible;
|
|
412
|
+
},
|
|
396
413
|
async renderAnnulusColorThumb(id, temp = 0) {
|
|
397
414
|
if (this.hideThumb) {
|
|
398
415
|
return;
|
|
@@ -430,7 +447,14 @@ export default Render({
|
|
|
430
447
|
(this.innerRingRadius + (this.radius - this.innerRingRadius) / 2) *
|
|
431
448
|
Math.sin((angle * Math.PI) / 180);
|
|
432
449
|
const { data } = ctx.getImageData(x * 2, y * 2, 1, 1);
|
|
433
|
-
|
|
450
|
+
const rgb = { r: data[0], g: data[1], b: data[2] };
|
|
451
|
+
this.updateThumbPosition(x, y, rgb);
|
|
452
|
+
const emitRes = {
|
|
453
|
+
position: { x, y },
|
|
454
|
+
touchType: this.touchType,
|
|
455
|
+
rgb,
|
|
456
|
+
};
|
|
457
|
+
this.callMethod('_getAnnulusImageData', emitRes);
|
|
434
458
|
},
|
|
435
459
|
updateThumbPosition(x, y, rgb) {
|
|
436
460
|
if (this.hideThumb) {
|
|
@@ -440,6 +464,15 @@ export default Render({
|
|
|
440
464
|
console.error('canvasThumb not found');
|
|
441
465
|
return;
|
|
442
466
|
}
|
|
467
|
+
if (typeof x !== 'number' || typeof y !== 'number') {
|
|
468
|
+
x = this.preX;
|
|
469
|
+
y = this.preY;
|
|
470
|
+
rgb = this.preRgb;
|
|
471
|
+
} else {
|
|
472
|
+
this.preX = x;
|
|
473
|
+
this.preY = y;
|
|
474
|
+
this.preRgb = rgb;
|
|
475
|
+
}
|
|
443
476
|
let ctx = this.canvasThumbCtx;
|
|
444
477
|
this.canvasThumb.width = this.radius * 4;
|
|
445
478
|
this.canvasThumb.height = this.radius * 4;
|
|
@@ -451,7 +484,7 @@ export default Render({
|
|
|
451
484
|
ctx.arc(x * 2, y * 2, radius, startAngle, endAngle, true);
|
|
452
485
|
ctx.shadowBlur = 24;
|
|
453
486
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.2)';
|
|
454
|
-
ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
|
487
|
+
ctx.fillStyle = this.inactive ? '#000000' : 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
|
455
488
|
ctx.fill();
|
|
456
489
|
|
|
457
490
|
if (this.touchCircleStrokeStyle) {
|
|
@@ -482,6 +515,7 @@ export default Render({
|
|
|
482
515
|
const emitRes = {
|
|
483
516
|
position: { x, y },
|
|
484
517
|
touchType: this.touchType,
|
|
518
|
+
rgb: { r, g, b },
|
|
485
519
|
};
|
|
486
520
|
this.callMethod('_getAnnulusImageData', emitRes);
|
|
487
521
|
|
|
@@ -543,6 +577,9 @@ export default Render({
|
|
|
543
577
|
}
|
|
544
578
|
},
|
|
545
579
|
handleCanvasStartEvent(evt) {
|
|
580
|
+
if (this.hideThumb) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
546
583
|
this.touchType = 'start';
|
|
547
584
|
const { changedTouches } = evt;
|
|
548
585
|
const [point] = changedTouches;
|
|
@@ -554,6 +591,9 @@ export default Render({
|
|
|
554
591
|
this._getRgb(validXY.x, validXY.y);
|
|
555
592
|
},
|
|
556
593
|
handleCanvasEndEvent(evt) {
|
|
594
|
+
if (this.hideThumb) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
557
597
|
this.touchType = 'end';
|
|
558
598
|
const { changedTouches } = evt;
|
|
559
599
|
const [point] = changedTouches;
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
canvas-id="{{ canvasId }}"
|
|
6
6
|
disable-scroll="true"
|
|
7
7
|
style="width: {{ radius * 2 }}px; height: {{ radius * 2 }}px;"
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/>
|
|
9
|
+
<view class="canvasPowerOffMask" style="position: absolute; top: 0; left: 0; width: {{ radius * 2 }}px; height: {{ radius * 2 }}px;" ty:if="{{ maskVisible }}" />
|
|
10
10
|
<canvas
|
|
11
11
|
class="canvasThumbWrapper"
|
|
12
12
|
type="2d"
|
|
13
13
|
canvas-id="{{ canvasId }}_thumb"
|
|
14
14
|
disable-scroll="true"
|
|
15
15
|
style="position: absolute; top: 0; left: 0; width: {{ radius * 2 }}px; height: {{ radius * 2 }}px;"
|
|
16
|
-
|
|
16
|
+
/>
|
|
17
17
|
</view>
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
3
|
+
import React, { useMemo, useState } from 'react';
|
|
4
4
|
import { View, Text } from '@ray-js/components';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Strings from './i18n';
|
|
@@ -23,6 +23,8 @@ const LampCirclePicker = props => {
|
|
|
23
23
|
showInnerCircle = true,
|
|
24
24
|
touchCircleLineWidth = 0,
|
|
25
25
|
touchCircleStrokeStyle = '',
|
|
26
|
+
inactive = false,
|
|
27
|
+
maskVisible = false,
|
|
26
28
|
innerBorderStyle = {
|
|
27
29
|
width: 5,
|
|
28
30
|
color: '#eee'
|
|
@@ -32,6 +34,7 @@ const LampCirclePicker = props => {
|
|
|
32
34
|
onTouchMove,
|
|
33
35
|
onTouchEnd
|
|
34
36
|
} = props;
|
|
37
|
+
const [innerCircleColor, setInnerCircleColor] = useState('');
|
|
35
38
|
const innerImgRadius = innerRingRadius * 4 * 0.8;
|
|
36
39
|
const _value = value !== null && value !== void 0 ? value : temperature;
|
|
37
40
|
const canvasId = useMemo(() => {
|
|
@@ -49,22 +52,7 @@ const LampCirclePicker = props => {
|
|
|
49
52
|
return /*#__PURE__*/React.createElement(View, {
|
|
50
53
|
className: clsx(styled.container, styled.flexCenter),
|
|
51
54
|
style: style
|
|
52
|
-
}, /*#__PURE__*/React.createElement(
|
|
53
|
-
canvasId: canvasId,
|
|
54
|
-
hideThumb: hideThumb,
|
|
55
|
-
value: _value,
|
|
56
|
-
radius: radius,
|
|
57
|
-
touchCircleLineWidth: touchCircleLineWidth,
|
|
58
|
-
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
59
|
-
innerRingRadius: innerRingRadius,
|
|
60
|
-
colorList: _colorList,
|
|
61
|
-
lineCap: lineCap,
|
|
62
|
-
useEventChannel: useEventChannel || false,
|
|
63
|
-
eventChannelName: eventChannelName,
|
|
64
|
-
onTouchStart: onTouchStart,
|
|
65
|
-
onTouchMove: onTouchMove,
|
|
66
|
-
onTouchEnd: onTouchEnd
|
|
67
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
55
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
68
56
|
className: clsx(styled.innerBox, styled.flexCenter)
|
|
69
57
|
}, showInnerCircle && /*#__PURE__*/React.createElement(View, {
|
|
70
58
|
className: styled.ringIcon,
|
|
@@ -72,7 +60,8 @@ const LampCirclePicker = props => {
|
|
|
72
60
|
width: innerImgRadius,
|
|
73
61
|
height: innerImgRadius,
|
|
74
62
|
borderRadius: innerImgRadius,
|
|
75
|
-
border: `${borderWidth}px solid ${borderColor}
|
|
63
|
+
border: `${borderWidth}px solid ${borderColor}`,
|
|
64
|
+
backgroundColor: innerCircleColor || 'transparent'
|
|
76
65
|
}
|
|
77
66
|
}), /*#__PURE__*/React.createElement(View, {
|
|
78
67
|
className: clsx(styled.textBox, styled.flexCenter)
|
|
@@ -82,7 +71,30 @@ const LampCirclePicker = props => {
|
|
|
82
71
|
}, Math.trunc(_value / 10), "%"), /*#__PURE__*/React.createElement(Text, {
|
|
83
72
|
className: styled.desc,
|
|
84
73
|
style: descStyle
|
|
85
|
-
}, descText !== null && descText !== void 0 ? descText : Strings.getLang('temperature'))))
|
|
74
|
+
}, descText !== null && descText !== void 0 ? descText : Strings.getLang('temperature')))), /*#__PURE__*/React.createElement(AnnulusPickerColor, {
|
|
75
|
+
canvasId: canvasId,
|
|
76
|
+
hideThumb: hideThumb,
|
|
77
|
+
value: _value,
|
|
78
|
+
radius: radius,
|
|
79
|
+
touchCircleLineWidth: touchCircleLineWidth,
|
|
80
|
+
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
81
|
+
innerRingRadius: innerRingRadius,
|
|
82
|
+
colorList: _colorList,
|
|
83
|
+
inactive: inactive,
|
|
84
|
+
maskVisible: maskVisible,
|
|
85
|
+
lineCap: lineCap,
|
|
86
|
+
useEventChannel: useEventChannel || false,
|
|
87
|
+
eventChannelName: eventChannelName,
|
|
88
|
+
onTouchStart: onTouchStart,
|
|
89
|
+
onTouchMove: onTouchMove,
|
|
90
|
+
onTouchEnd: (v, rgb) => {
|
|
91
|
+
setInnerCircleColor(`rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`);
|
|
92
|
+
onTouchEnd === null || onTouchEnd === void 0 || onTouchEnd(v);
|
|
93
|
+
},
|
|
94
|
+
onInit: (v, rgb) => {
|
|
95
|
+
setInnerCircleColor(`rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`);
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
86
98
|
};
|
|
87
99
|
const nilFn = () => null;
|
|
88
100
|
LampCirclePicker.defaultProps = {
|
|
@@ -105,6 +117,7 @@ LampCirclePicker.defaultProps = {
|
|
|
105
117
|
style: {},
|
|
106
118
|
onTouchStart: nilFn,
|
|
107
119
|
onTouchMove: nilFn,
|
|
108
|
-
onTouchEnd: nilFn
|
|
120
|
+
onTouchEnd: nilFn,
|
|
121
|
+
onInit: nilFn
|
|
109
122
|
};
|
|
110
123
|
export default LampCirclePicker;
|
package/lib/index.module.less
CHANGED
package/lib/props.d.ts
CHANGED
|
@@ -45,8 +45,8 @@ export interface IProps {
|
|
|
45
45
|
*/
|
|
46
46
|
onTouchStart?: (value: number) => void;
|
|
47
47
|
/**
|
|
48
|
-
* @description.zh
|
|
49
|
-
* @description.en Finger to press the drag of the callback function
|
|
48
|
+
* @description.zh 手指按下拖动时的回调函数, 一般不建议使用,存在性能问题, 使用的话 也需要添加节流防止高频触发
|
|
49
|
+
* @description.en Finger to press the drag of the callback function, not recommended to use, there is a performance problem, if used, it is also necessary to add throttle to prevent high-frequency triggering
|
|
50
50
|
* @default ''
|
|
51
51
|
*/
|
|
52
52
|
onTouchMove?: (value: number) => void;
|
|
@@ -68,6 +68,20 @@ export interface IProps {
|
|
|
68
68
|
* @default false
|
|
69
69
|
*/
|
|
70
70
|
useEventChannel?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @description.en inactive
|
|
73
|
+
* @description.zh 关闭状态
|
|
74
|
+
* @default false
|
|
75
|
+
* @version 1.1.0
|
|
76
|
+
*/
|
|
77
|
+
inactive?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @description.en maskVisible
|
|
80
|
+
* @description.zh 是否显示遮罩
|
|
81
|
+
* @default false
|
|
82
|
+
* @version 1.1.0
|
|
83
|
+
*/
|
|
84
|
+
maskVisible?: boolean;
|
|
71
85
|
/**
|
|
72
86
|
* @description.en eventChannelName
|
|
73
87
|
* @description.zh 事件名
|