Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added option 'angleBgCircle' || default = false

'angleBgCircle' show a full circle background when 'angleArc' is less
than 360 degrees.
  • Loading branch information...
commit 3cc11253dda6d022ba17d89e044bf5ece4f32725 1 parent 2734c27
@FabrizioC authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 js/jquery.knob.js
View
12 js/jquery.knob.js
@@ -36,8 +36,10 @@ $(function () {
} else {
var b, a;
b = a = Math.atan2(mx - x, -(my - y - opt.width / 2)) - opt.angleOffset;
- (a < 0) && (b = a + PI2);
- nv = Math.round(b * (opt.max - opt.min) / PI2) + opt.min;
+// (a < 0) && (b = a + PI2);
+ (a < 0) && (b = a + opt.angleArc);
+// nv = Math.round(b * (opt.max - opt.min) / PI2) + opt.min;
+ nv = Math.round(b * (opt.max - opt.min) / opt.angleArc) + opt.min;
return (nv > opt.max) ? opt.max : nv;
}
};
@@ -63,6 +65,8 @@ $(function () {
,lw = r * opt.thickness // Line width
,cgcolor = Dial.getCgColor(opt.cgColor)
,tick
+ ,bsa = sa
+ ,bea = bsa + (opt.angleBgCircle ? (2 * Math.PI) : opt.angleArc)
;
ctx.clearRect(0, 0, opt.width, opt.width);
@@ -98,7 +102,7 @@ $(function () {
ctx.beginPath();
ctx.strokeStyle = opt.bgColor;
- ctx.arc(r, r, r - lw / 2, 0, PI2, true);
+ ctx.arc(r, r, r - lw / 2, bea, bsa, true);
ctx.stroke();
if (opt.displayPrevious) {
@@ -244,6 +248,8 @@ $(function () {
,'skin' : $this.data('skin') || 'default'
,'angleOffset': degreeToRadians($this.data('angleoffset'))
,'angleArc': degreeToRadians($this.data('anglearc')) || 2 * Math.PI
+ ,'angleBgCircle': $this.data('anglebgcircle') || false
+
// Hooks
,'draw' :
Please sign in to comment.
Something went wrong with that request. Please try again.