Skip to content

Commit

Permalink
fix: check that coordinates are actual numbers before proceeding with…
Browse files Browse the repository at this point in the history
… syncing values
  • Loading branch information
iOvergaard committed Sep 21, 2023
1 parent 68522f3 commit e747ad0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/uui-color-area/lib/uui-color-area.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export class UUIColorAreaElement extends LitElement {

drag(grid, {
onMove: (x, y) => {
// check if coordinates are not NaN (can happen when dragging outside of the grid)
if (isNaN(x) || isNaN(y)) return;

this.saturation = clamp((x / width) * 100, 0, 100);
this.brightness = clamp(100 - (y / height) * 100, 0, 100);
this.lightness = this.getLightness(this.brightness);
Expand Down

0 comments on commit e747ad0

Please sign in to comment.