Compare commits

...

2 Commits

Author SHA1 Message Date
zh
32066bbf99 修改自定义颜色插件 2025-07-16 17:45:32 +08:00
zh
6a71f41a19 修改自定义颜色插件 2025-07-16 16:03:14 +08:00
2 changed files with 16 additions and 12 deletions

View File

@ -11,7 +11,7 @@ class YJColorPicker {
clickDefineColor: clickDefineColor, clickDefineColor: clickDefineColor,
hasClear: true, hasClear: true,
openPickerAni: 'opacity', openPickerAni: 'opacity',
defaultColor: options.defaultColor || '#ffffff', defaultColor: options.defaultColor,
startMainCallback: (t) => { startMainCallback: (t) => {
customizeStyle() customizeStyle()
} }
@ -37,6 +37,7 @@ class YJColorPicker {
if (pickAlphaInput) { if (pickAlphaInput) {
pickAlphaInput.value = this.pickAlphaInputValue = 100 pickAlphaInput.value = this.pickAlphaInputValue = 100
} }
this.colorPicker.config.defaultColor = ''
customizeStyle() customizeStyle()
if (typeof options.clear == 'function') { if (typeof options.clear == 'function') {
options.clear() options.clear()
@ -51,9 +52,8 @@ class YJColorPicker {
// }, this.colorPicker.config.pickerAnimationTime); // }, this.colorPicker.config.pickerAnimationTime);
} }
} }
let CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor) let CesiumColor
if (!CesiumColor) { if(config.defaultColor) {
config.defaultColor = '#ffffff'
CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor) CesiumColor = Cesium.Color.fromCssColorString(config.defaultColor)
} }
// if (options.predefineColor) { // if (options.predefineColor) {
@ -61,7 +61,7 @@ class YJColorPicker {
// } // }
config.predefineColor = ['rgba(255, 255, 255, 1)', 'rgba(255, 0, 0, 1)', 'rgba(208, 132, 209, 1)', 'rgba(100, 182, 217, 1)', 'rgba(42, 130, 228, 1)', 'rgba(214, 36, 36, 1)', 'rgba(252, 222, 111, 1)', 'rgba(67, 207, 124, 1)', 'rgba(176, 243, 143, 1)', 'rgba(121, 72, 234, 1)', 'rgba(255, 195, 0, 1)', 'rgba(0, 186, 173, 1)', 'rgba(165, 214, 63, 1)', 'rgba(0, 0, 0, 1)', 'rgba(46, 47, 51, 1)', 'rgba(172, 51, 193, 1)', 'rgba(130, 21, 21, 1)', 'rgba(255, 87, 51, 1)', 'rgba(255, 140, 0, 1)', 'rgba(125, 191, 255, 1)'] config.predefineColor = ['rgba(255, 255, 255, 1)', 'rgba(255, 0, 0, 1)', 'rgba(208, 132, 209, 1)', 'rgba(100, 182, 217, 1)', 'rgba(42, 130, 228, 1)', 'rgba(214, 36, 36, 1)', 'rgba(252, 222, 111, 1)', 'rgba(67, 207, 124, 1)', 'rgba(176, 243, 143, 1)', 'rgba(121, 72, 234, 1)', 'rgba(255, 195, 0, 1)', 'rgba(0, 186, 173, 1)', 'rgba(165, 214, 63, 1)', 'rgba(0, 0, 0, 1)', 'rgba(46, 47, 51, 1)', 'rgba(172, 51, 193, 1)', 'rgba(130, 21, 21, 1)', 'rgba(255, 87, 51, 1)', 'rgba(255, 140, 0, 1)', 'rgba(125, 191, 255, 1)']
this.colorPicker = new ewPlugins('colorpicker', config) this.colorPicker = new ewPlugins('colorpicker', config)
window.colorPicker = this.colorPicker // window.colorPicker = this.colorPicker
customizeStyle() customizeStyle()
@ -114,20 +114,20 @@ class YJColorPicker {
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min) value = Number(e.target.dataset.min)
} }
pickAlphaInput.value = value pickAlphaInput.value = Number(value.toFixed(2))
} }
}) })
if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') { if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') {
pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2)) pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2))
} }
else { else {
pickAlphaInput.value = Number((CesiumColor.alpha * 100).toFixed(2)) pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(2)) : 100
} }
_this.pickAlphaInputValue = pickAlphaInput.value _this.pickAlphaInputValue = pickAlphaInput.value
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString() box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString()
} }
else { else {
CesiumColor = CesiumColor.withAlpha(1) CesiumColor = CesiumColor ? CesiumColor.withAlpha(1) : ''
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssColorString() box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').toCssColorString()
} }
@ -268,7 +268,7 @@ class YJColorPicker {
function clickDefineColor(color) { function clickDefineColor(color) {
if (pickAlphaInput) { if (pickAlphaInput) {
let c = Cesium.Color.fromCssColorString(color) let c = Cesium.Color.fromCssColorString(color)
pickAlphaInput.value = c.alpha * 100 pickAlphaInput.value = Number((c.alpha * 100).toFixed(2))
} }
} }

View File

@ -740,7 +740,7 @@
function p(e, t) { function p(e, t) {
// c(e.box, "background", (0, // c(e.box, "background", (0,
// o.colorHsbaToRgba)(e.hsba)), // o.colorHsbaToRgba)(e.hsba)),
c(e.arrowRight, "border-top-color", (0, e.arrowRight && c(e.arrowRight, "border-top-color", (0,
o.colorHsbaToRgba)(e.hsba)), o.colorHsbaToRgba)(e.hsba)),
t || e.config.alpha ? e.pickerInput.value = (0, t || e.config.alpha ? e.pickerInput.value = (0,
o.colorHsbaToRgba)(e.hsba) : e.pickerInput.value = (0, o.colorHsbaToRgba)(e.hsba) : e.pickerInput.value = (0,
@ -796,7 +796,9 @@
clear: (0, clear: (0,
n.isFunction)(e.clear) ? e.clear : null, n.isFunction)(e.clear) ? e.clear : null,
startMainCallback: (0, startMainCallback: (0,
n.isFunction)(e.startMainCallback) ? e.startMainCallback : null n.isFunction)(e.startMainCallback) ? e.startMainCallback : null,
clickDefineColor: (0,
n.isFunction)(e.clickDefineColor) ? e.clickDefineColor : null
}, },
o.length) o.length)
for (var i = 0; i < o.length; ) for (var i = 0; i < o.length; )
@ -1019,7 +1021,9 @@
r.hsba = t, r.hsba = t,
p(r), p(r),
h(r), h(r),
g(r, i, a) g(r, i, a),
r.config.clickDefineColor && r.config.clickDefineColor((0,
n.getCss)(e.target, "background-color"))
}, !1), }, !1),
e.addEventListener("blur", function(e) { e.addEventListener("blur", function(e) {
(0, (0,