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
9 changes: 6 additions & 3 deletions TangleKit/TangleKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Tangle.classes.TKNumberField = {
// Attributes: data-min (optional): minimum value
// data-max (optional): maximum value
// data-step (optional): granularity of adjustment (can be fractional)
// data-scale (optional): rate of drag movements

var isAnyAdjustableNumberDragging = false; // hack for dragging one value over another one

Expand All @@ -144,6 +145,8 @@ Tangle.classes.TKAdjustableNumber = {
this.min = (options.min !== undefined) ? parseFloat(options.min) : 0;
this.max = (options.max !== undefined) ? parseFloat(options.max) : 1e100;
this.step = (options.step !== undefined) ? parseFloat(options.step) : 1;
this.scale = (options.scale !== undefined) ? parseFloat(options.scale) : 1/5;
this.digits = (""+this.step).split('.')[1].length;

this.initializeHover();
this.initializeHelp();
Expand Down Expand Up @@ -217,9 +220,9 @@ Tangle.classes.TKAdjustableNumber = {
},

touchDidMove: function (touches) {
var value = this.valueAtMouseDown + touches.translation.x / 5 * this.step;
value = ((value / this.step).round() * this.step).limit(this.min, this.max);
this.tangle.setValue(this.variable, value);
var value = this.valueAtMouseDown + touches.translation.x * this.scale * this.step;
value = ((value / this.step).round() * this.step).limit(this.min, this.max).toFixed(this.digits);
this.tangle.setValue(this.variable, parseFloat(value, 10));
this.updateHelp();
},

Expand Down