Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions www/js/jquery.knob.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
this.$c = null; // jQuery canvas element
this.c = null; // rendered canvas context
this.t = 0; // touches index
this.ga = null; // gesture angle ; tracks the arc during a drag
this.isInit = false;
this.fgColor = null; // main color
this.pColor = null; // previous color
Expand Down Expand Up @@ -323,7 +324,8 @@
// get touches index
this.t = k.c.t(e);

// First touch
// First touch is absolute
s.ga = null;
touchMove(e);

// Touch events listeners
Expand Down Expand Up @@ -370,7 +372,8 @@
s._draw();
};

// First click
// First click is absolute
s.ga = null;
mouseMove(e);

// Mouse events listeners
Expand Down Expand Up @@ -567,6 +570,19 @@
a += this.PI2;
}

// Follow the arc during a drag instead of jumping across the seam
// where min and max meet
if (this.ga !== null) {
var d = a - this.ga;
if (d > Math.PI) {
d -= this.PI2;
} else if (d < -Math.PI) {
d += this.PI2;
}
a = max(0, min(this.angleArc, this.ga + d));
}
this.ga = a;

ret = ~~ (0.5 + (a * (this.o.max - this.o.min) / this.angleArc))
+ this.o.min;

Expand Down