Skip to content

Commit

Permalink
优化工程结构
Browse files Browse the repository at this point in the history
  • Loading branch information
caiwuu committed Feb 28, 2024
1 parent f397480 commit 3551afc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/editor/toolBar/compinents/colorPicker/hue.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ export default class Hue extends Component {
handleHueChange = throttle((e) => {
pauseEvent(e)
const x = typeof e.pageX === 'number' ? e.pageX : e.touches[0].pageX
let left = x - (this.hueContainer.current.getBoundingClientRect().left + window.pageXOffset)
let left = x - (this.hueContainer.current.getBoundingClientRect().left + window.scrollX)
left = left >= 200 ? 200 : left <= 0 ? 0 : left
const hue = (1 - left / 200) * 360
const [R, G, B] = coordinatesToRgb(
hue,
this.props.paletteRef.current.state.px,
this.props.paletteRef.current.state.py
)
console.log(this.props.paletteRef.current.state);
this.color = `rgba(${R},${G},${B},${this.state.A})`
this.setState({ x: left <= 6 ? 6 : left, R, G, B })
this.props.paletteRef.current.setPalette(hue)
Expand All @@ -95,7 +96,7 @@ export default class Hue extends Component {
pauseEvent(e)
const x = typeof e.pageX === 'number' ? e.pageX : e.touches[0].pageX
let left =
x - (this.transparencyContainer.current.getBoundingClientRect().left + window.pageXOffset)
x - (this.transparencyContainer.current.getBoundingClientRect().left + window.scrollX)
left = left >= 200 ? 200 : left <= 0 ? 0 : left
const A = left / 200
this.color = `rgba(${this.state.R},${this.state.G},${this.state.B},${A})`
Expand Down

0 comments on commit 3551afc

Please sign in to comment.