Skip to content

Commit

Permalink
refactor: CSS-only active drag state
Browse files Browse the repository at this point in the history
  • Loading branch information
rkunev committed Jan 21, 2024
1 parent 6bfa74b commit b19f48c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/ColorPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:aria-valuetext="ariaValuetext || valuetext"
:aria-disabled="disabled"
class="rcp"
:class="{ dragging: isDragging }"
:tabindex="disabled ? -1 : 0"
:style="{ '--rcp-initial-angle': initialAngle }"
@keyup.enter="selectColor"
Expand Down Expand Up @@ -121,7 +120,6 @@
const isKnobIn = ref(!props.initiallyCollapsed);
const isPressed = ref(false);
const isRippling = ref(false);
const isDragging = ref(false);
const color = computed(
() => `hsla(${angle.value}, ${props.saturation}%, ${props.luminosity}%, ${props.alpha})`
Expand Down Expand Up @@ -156,11 +154,7 @@
angle.value = hue;
emit('input', angle.value);
},
onDragStart() {
isDragging.value = true;
},
onDragStop() {
isDragging.value = false;
emit('change', angle.value);
},
});
Expand Down Expand Up @@ -243,7 +237,6 @@
angle,
isPaletteIn,
isKnobIn,
isDragging,
isRippling,
isPressed,
Expand Down Expand Up @@ -300,7 +293,7 @@
box-shadow: 0 0 20px rgba(0, 0, 0, 0.19), 0 0 10px rgba(0, 0, 0, 0.24);
}
/* Allow clicking through the transparent area surrounding the well when collapsed */
/* Allow tapping through the transparent area surrounding the well when collapsed */
.rcp[aria-expanded='false'] {
pointer-events: none;
}
Expand All @@ -309,7 +302,8 @@
pointer-events: auto;
}
.rcp.dragging {
/* Slightly scale up the color picker when rotating, but not when tapping the well */
.rcp:active:focus {
transform: scale(1.04);
}
Expand Down

0 comments on commit b19f48c

Please sign in to comment.