Class: Field {#Field}
Extends
Implements
Field Method: constructor {#Field:constructor}
Syntax:
var myField = new Field(field, knob, [options]);
Arguments:
- field (mixed) - The element which will act as the field or the id as a string.
- knob (mixed) - The element which will act as the knob or the id as a string.
- options (object, optional) - An object with class options, see below.
Options:
- x (array) An array of the form [min, step, max]. If max is left as false, the width of the field is used.
- y (array) An array of the form [min, step, max]. If max is left as false, the height of the field is used.
- setOnClick (boolean) If true clicking the field will make the knob jump to that location. (Default to true)
- initialStep (object) An object with the x and y steps of the initial position.
Events:
- onTick (function) Event fires while the knob is dragged. Returns an object with the 'x' and 'y' values of the knob.
- onComplete (function) Event fires when the position change is complete (Knob dropped or position set). Returns an object with the 'x' and 'y' values of the knob.
- onChange (function) Event fires when the value of the field is changed. Returns an object with the 'x' and 'y' values of the knob.
Field Method: set {#Field:set}
Sets the step of the field. The values can't accede the 'max' and 'min' options.
Arguments:
- steps (object) An object with 'x' and 'y' for the new position of the knob.
Field Method: get {#Field:get}
Returns the current step of the field.
Returns:
- steps (object) An object with 'x' and 'y' for the position of the knob.
Field Method: setRanges {#Field:setRanges}
Changes the range of the field.
Arguments:
- ranges (object) An object with 'x' and 'y' for the ranges. Uses the same format as the options 'x' and 'y'.
Field Method: attach {#Field:attach}
Attaches the mouse listeners making the field draggable (and clickable)
Returns:
- (object) The field instance.
Field Method: detach {#Field:detach}
Detaches the mouse listeners making the field not draggable (and clickable)
Returns:
- (object) The field instance.