@ray-js/lamp-circle-picker 1.0.9-beta-1 → 1.0.10-beta-1
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/README.md +34 -0
- package/lib/component/index.js +2 -0
- package/lib/component/rjs/index.rjs +19 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,40 @@ interface IProps {
|
|
|
62
62
|
*/
|
|
63
63
|
eventChannelName?: string;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* @description.en showInnerCircle
|
|
67
|
+
* @description.zh 展示数值圆环
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
showInnerCircle?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @description.en descText
|
|
73
|
+
* @description.zh 色环内部文字
|
|
74
|
+
* @default null
|
|
75
|
+
*/
|
|
76
|
+
descText?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @description.en innerBorderStyle
|
|
79
|
+
* @description.zh 内部圆环描边
|
|
80
|
+
* @default null
|
|
81
|
+
*/
|
|
82
|
+
innerBorderStyle?: {
|
|
83
|
+
color: string;
|
|
84
|
+
width: number;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @description.en touchCircleStrokeStyle
|
|
89
|
+
* @description.zh 触摸圆环描边颜色与 ctx.shadowColor 值相同
|
|
90
|
+
* @default null
|
|
91
|
+
*/
|
|
92
|
+
touchCircleStrokeStyle?: string;
|
|
93
|
+
/**
|
|
94
|
+
* @description.en touchCircleLineWidth
|
|
95
|
+
* @description.zh 触摸圆环描边宽度与 ctx.shadowBlur 值相同
|
|
96
|
+
* @default null
|
|
97
|
+
*/
|
|
98
|
+
touchCircleLineWidth?: number;
|
|
65
99
|
/**
|
|
66
100
|
* @description.zh 手指按下时的回调函数
|
|
67
101
|
* @description.en Finger press when the callback function
|
package/lib/component/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export default function RectColor(props) {
|
|
|
10
10
|
colorList: props.colorList,
|
|
11
11
|
useEventChannel: props.useEventChannel,
|
|
12
12
|
eventChannelName: props.eventChannelName,
|
|
13
|
+
touchCircleStrokeStyle: props.touchCircleStrokeStyle,
|
|
14
|
+
touchCircleLineWidth: props.touchCircleLineWidth,
|
|
13
15
|
bindstart: function onTouchStart(e) {
|
|
14
16
|
var detail = e.detail;
|
|
15
17
|
var temp = Math.floor(detail);
|
|
@@ -7,9 +7,10 @@ export default Render({
|
|
|
7
7
|
// 环形色盘
|
|
8
8
|
async renderAnnulusColor(id, radius, innerRingRadius, temp = 0, options = {}) {
|
|
9
9
|
let canvas = null;
|
|
10
|
-
const { touchCircleStrokeStyle, touchCircleLineWidth } = options || {}
|
|
11
|
-
this.touchCircleStrokeStyle = touchCircleStrokeStyle
|
|
12
|
-
this.touchCircleLineWidth = touchCircleLineWidth
|
|
10
|
+
const { touchCircleStrokeStyle, touchCircleLineWidth } = options || {};
|
|
11
|
+
this.touchCircleStrokeStyle = touchCircleStrokeStyle;
|
|
12
|
+
this.touchCircleLineWidth = touchCircleLineWidth;
|
|
13
|
+
|
|
13
14
|
try {
|
|
14
15
|
canvas = await getCanvasById(id);
|
|
15
16
|
} catch (error) {
|
|
@@ -39,15 +40,11 @@ export default Render({
|
|
|
39
40
|
endAngle
|
|
40
41
|
);
|
|
41
42
|
|
|
42
|
-
let grd = ctx.createConicGradient(
|
|
43
|
-
startAngle - Math.PI * 0.1,
|
|
44
|
-
radius * 2,
|
|
45
|
-
radius * 2,
|
|
46
|
-
);
|
|
43
|
+
let grd = ctx.createConicGradient(startAngle - Math.PI * 0.1, radius * 2, radius * 2);
|
|
47
44
|
|
|
48
|
-
options.colorList?.forEach(
|
|
45
|
+
options.colorList?.forEach(item => {
|
|
49
46
|
grd.addColorStop(item.offset, item.color);
|
|
50
|
-
})
|
|
47
|
+
});
|
|
51
48
|
|
|
52
49
|
//设定曲线粗细度
|
|
53
50
|
ctx.lineWidth = (radius - innerRingRadius) * 2;
|
|
@@ -63,7 +60,7 @@ export default Render({
|
|
|
63
60
|
canvas.style.height = `${radius * 2}px`;
|
|
64
61
|
this.annulusContext = ctx;
|
|
65
62
|
this.renderAnnulusColorThumb(id, temp);
|
|
66
|
-
this.callMethod('initedCanvas', {})
|
|
63
|
+
this.callMethod('initedCanvas', {});
|
|
67
64
|
},
|
|
68
65
|
async renderAnnulusColorThumb(id, temp = 0) {
|
|
69
66
|
if (!this.canvasThumb) {
|
|
@@ -114,11 +111,11 @@ export default Render({
|
|
|
114
111
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.2)';
|
|
115
112
|
ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
|
116
113
|
ctx.fill();
|
|
117
|
-
|
|
118
|
-
if(this.touchCircleStrokeStyle) {
|
|
114
|
+
|
|
115
|
+
if (this.touchCircleStrokeStyle) {
|
|
119
116
|
ctx.shadowColor = this.touchCircleStrokeStyle;
|
|
120
117
|
}
|
|
121
|
-
if(this.touchCircleLineWidth) {
|
|
118
|
+
if (this.touchCircleLineWidth) {
|
|
122
119
|
ctx.shadowBlur = this.touchCircleLineWidth;
|
|
123
120
|
}
|
|
124
121
|
|
|
@@ -190,13 +187,15 @@ export default Render({
|
|
|
190
187
|
return { x: thumbPositionX, y: thumbPositionY };
|
|
191
188
|
}
|
|
192
189
|
if (angle > 115 && angle <= 135) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const thumbPositionY =
|
|
190
|
+
// 修正在范围外的点击区域导致的取色问题
|
|
191
|
+
const _angle = 135;
|
|
192
|
+
const realAngle = ((180 - _angle) / 180) * Math.PI;
|
|
193
|
+
|
|
194
|
+
const thumbPositionY =
|
|
195
|
+
radius + (innerRingRadius + (radius - innerRingRadius) / 2) * Math.sin(realAngle);
|
|
198
196
|
|
|
199
|
-
const thumbPositionX =
|
|
197
|
+
const thumbPositionX =
|
|
198
|
+
radius - (innerRingRadius + (radius - innerRingRadius) / 2) * Math.cos(realAngle);
|
|
200
199
|
|
|
201
200
|
return { x: thumbPositionX, y: thumbPositionY };
|
|
202
201
|
}
|