diff --git a/src/components/white-balance/color-slider.tsx b/src/components/white-balance/color-slider.tsx index 0240e5b..bd4611b 100644 --- a/src/components/white-balance/color-slider.tsx +++ b/src/components/white-balance/color-slider.tsx @@ -5,6 +5,16 @@ type Props = { } & JSX.HTMLAttributes; export const ColorSlider: Component = (props) => { + const handleMouseDown = (e: MouseEvent) => { + // 阻止事件冒泡到父元素,避免触发面板拖拽 + e.stopPropagation(); + }; + + const handleMouseMove = (e: MouseEvent) => { + // 阻止事件冒泡到父元素 + e.stopPropagation(); + }; + return ( = (props) => { 'range range-primary w-full bg-gradient-to-r ' + props.class } + onMouseDown={handleMouseDown} + onMouseMove={handleMouseMove} /> ); }; diff --git a/src/components/white-balance/white-balance.tsx b/src/components/white-balance/white-balance.tsx index 286a407..c965775 100644 --- a/src/components/white-balance/white-balance.tsx +++ b/src/components/white-balance/white-balance.tsx @@ -56,13 +56,17 @@ export const WhiteBalance = () => { // 拖拽处理函数 const handleMouseDown = (e: MouseEvent) => { + // 确保只有在标题栏区域点击时才触发拖拽 setIsDragging(true); - const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); - setDragOffset({ - x: e.clientX - rect.left, - y: e.clientY - rect.top - }); + const panelRect = (e.currentTarget as HTMLElement).closest('.fixed')?.getBoundingClientRect(); + if (panelRect) { + setDragOffset({ + x: e.clientX - panelRect.left, + y: e.clientY - panelRect.top + }); + } e.preventDefault(); + e.stopPropagation(); }; const handleMouseMove = (e: MouseEvent) => { @@ -338,22 +342,24 @@ export const WhiteBalance = () => { {/* 可拖拽的RGB控制面板 */}
-
+
⋮⋮ RGB调节
可拖拽
-