fix(volume): kill the slider rubberband on release
The live-drag thumb reverted to the round-tripped bound value on release; because that value echoes back asynchronously the thumb snapped to the stale position then to the fresh one (a rubberband bounce). The thumb now tracks drag-fraction, which stays put on release and re-syncs to the external value only when it changes on its own (MPRIS / keyboard) while not dragging. cc
This commit is contained in:
2 files changed
+27
-11
No files matched your search
@@ -28,11 +28,19 @@ export component QbzSlider inherits Rectangle {
|
|||||||
// Travel range for the thumb centre.
|
// Travel range for the thumb centre.
|
||||||
property <length> travel: root.width - root.thumb-size;
|
property <length> travel: root.width - root.thumb-size;
|
||||||
|
|
||||||
// Live drag: while held, the thumb tracks the POINTER (continuous, no round-
|
// Live drag: the thumb tracks `drag-fraction`, which follows the POINTER
|
||||||
// trip through the bound value) so it never visibly steps between levels.
|
// while held and STAYS PUT on release — it never snaps back to the async
|
||||||
|
// round-tripped bound value (that snap-back was the rubberband). It re-syncs
|
||||||
|
// to the external value only when the value changes on its own (MPRIS /
|
||||||
|
// keyboard) while not dragging.
|
||||||
property <bool> dragging: false;
|
property <bool> dragging: false;
|
||||||
property <float> live-fraction: 0.0;
|
property <float> drag-fraction: root.fraction;
|
||||||
property <float> shown-fraction: root.dragging ? root.live-fraction : root.fraction;
|
property <float> shown-fraction: root.drag-fraction;
|
||||||
|
changed fraction => {
|
||||||
|
if (!root.dragging) {
|
||||||
|
root.drag-fraction = root.fraction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Track. HC-only outline so the rail stays visible when accent flattens.
|
// Track. HC-only outline so the rail stays visible when accent flattens.
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -82,7 +90,7 @@ export component QbzSlider inherits Rectangle {
|
|||||||
pointer-event(e) => {
|
pointer-event(e) => {
|
||||||
if (e.kind == PointerEventKind.down) {
|
if (e.kind == PointerEventKind.down) {
|
||||||
root.dragging = true;
|
root.dragging = true;
|
||||||
root.live-fraction = root.fraction-from-x(self.mouse-x);
|
root.drag-fraction = root.fraction-from-x(self.mouse-x);
|
||||||
if (root.value-from-x(self.mouse-x) != root.value) {
|
if (root.value-from-x(self.mouse-x) != root.value) {
|
||||||
root.changed(root.value-from-x(self.mouse-x));
|
root.changed(root.value-from-x(self.mouse-x));
|
||||||
}
|
}
|
||||||
@@ -95,7 +103,7 @@ export component QbzSlider inherits Rectangle {
|
|||||||
// Continuous drag while held — thumb follows the pointer every frame.
|
// Continuous drag while held — thumb follows the pointer every frame.
|
||||||
moved => {
|
moved => {
|
||||||
if (root.dragging) {
|
if (root.dragging) {
|
||||||
root.live-fraction = root.fraction-from-x(self.mouse-x);
|
root.drag-fraction = root.fraction-from-x(self.mouse-x);
|
||||||
if (root.value-from-x(self.mouse-x) != root.value) {
|
if (root.value-from-x(self.mouse-x) != root.value) {
|
||||||
root.changed(root.value-from-x(self.mouse-x));
|
root.changed(root.value-from-x(self.mouse-x));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,18 @@ export component QbzVerticalSlider inherits Rectangle {
|
|||||||
// Travel range for the thumb centre (top..bottom of the column).
|
// Travel range for the thumb centre (top..bottom of the column).
|
||||||
property <length> travel: root.height - root.thumb-size;
|
property <length> travel: root.height - root.thumb-size;
|
||||||
|
|
||||||
// Live drag: while held, the thumb tracks the POINTER directly.
|
// Live drag: the thumb tracks `drag-fraction`, which follows the POINTER
|
||||||
|
// while held and STAYS PUT on release (no snap-back to the async round-
|
||||||
|
// tripped value = the rubberband); it re-syncs to the external value only
|
||||||
|
// when that value changes on its own while not dragging.
|
||||||
property <bool> dragging: false;
|
property <bool> dragging: false;
|
||||||
property <float> live-fraction: 0.0;
|
property <float> drag-fraction: root.fraction;
|
||||||
property <float> shown-fraction: root.dragging ? root.live-fraction : root.fraction;
|
property <float> shown-fraction: root.drag-fraction;
|
||||||
|
changed fraction => {
|
||||||
|
if (!root.dragging) {
|
||||||
|
root.drag-fraction = root.fraction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Track (the full vertical rail). HC-only outline keeps the rail visible
|
// Track (the full vertical rail). HC-only outline keeps the rail visible
|
||||||
// when accent flattens.
|
// when accent flattens.
|
||||||
@@ -81,7 +89,7 @@ export component QbzVerticalSlider inherits Rectangle {
|
|||||||
pointer-event(e) => {
|
pointer-event(e) => {
|
||||||
if (e.kind == PointerEventKind.down) {
|
if (e.kind == PointerEventKind.down) {
|
||||||
root.dragging = true;
|
root.dragging = true;
|
||||||
root.live-fraction = root.fraction-from-y(self.mouse-y);
|
root.drag-fraction = root.fraction-from-y(self.mouse-y);
|
||||||
if (root.value-from-y(self.mouse-y) != root.value) {
|
if (root.value-from-y(self.mouse-y) != root.value) {
|
||||||
root.changed(root.value-from-y(self.mouse-y));
|
root.changed(root.value-from-y(self.mouse-y));
|
||||||
}
|
}
|
||||||
@@ -93,7 +101,7 @@ export component QbzVerticalSlider inherits Rectangle {
|
|||||||
// Continuous drag while held — thumb follows the pointer every frame.
|
// Continuous drag while held — thumb follows the pointer every frame.
|
||||||
moved => {
|
moved => {
|
||||||
if (root.dragging) {
|
if (root.dragging) {
|
||||||
root.live-fraction = root.fraction-from-y(self.mouse-y);
|
root.drag-fraction = root.fraction-from-y(self.mouse-y);
|
||||||
if (root.value-from-y(self.mouse-y) != root.value) {
|
if (root.value-from-y(self.mouse-y) != root.value) {
|
||||||
root.changed(root.value-from-y(self.mouse-y));
|
root.changed(root.value-from-y(self.mouse-y));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user