# JSDoc: Class: Slider

# Class: Slider

## visual.Slider(options)

#### new Slider(options)

Slider stimulus.

##### Parameters:

Name | Type | Description
--- | --- | ---

`options`

Object

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`name` | String |  |  | the name used when logging messages from this stimulus
`win` | module:core.Window |  |  | the associated Window
`pos` | Array.<number> | <optional> | [0, 0] | the position of the center of the slider
`size` | Array.<number> |  |  | the size of the slider, e.g. [1, 0.1] for an horizontal slider
`ori` | number | <optional> | 0.0 | the orientation (in degrees)
`units` | string | <optional> | 'height' | the units of the Slider position, and font size
`color` | Color | <optional> | Color('LightGray') | the color of the slider
`contrast` | number | <optional> | 1.0 | the contrast of the slider
`opacity` | number | <optional> | 1.0 | the opacity of the slider
`style` | string | <optional> | [Slider.Style.RATING] | the slider style
`ticks` | Array.<number> | <optional> | [1,2,3,4,5] | the array of ticks
`labels` | Array.<number> | <optional> | [] | the array of labels
`granularity` | number | <optional> | 0 | the granularity
`flip` | boolean | <optional> | false | whether or not to flip the position of the marker, ticks, and labels with respect to the central bar
`readOnly` | boolean | <optional> | false | whether or not the slider is read only
`font` | string | <optional> | 'Arial' | the text font
`bold` | boolean | <optional> | true | whether or not the font of the labels is bold
`italic` | boolean | <optional> | false | whether or not the font of the labels is italic
`fontSize` | number | <optional> |  | the font size of the labels (in pixels), the default fontSize depends on the Slider's units: 14 for 'pix', 0.03 otherwise
`compact` | boolean | <optional> | false | whether or not the slider is compact, i.e. whether all graphical elements (e.g. labels) fit within its size
`clipMask` | PIXI.Graphics |  |  | the clip mask
`autoDraw` | boolean | <optional> | false | whether or not the stimulus should be automatically drawn on every frame flip
`autoLog` | boolean | <optional> | false | whether or not to log
`dependentStims` | Array.<core.MinimalStim> | <optional> | [] | the list of dependent stimuli, which must be updated when this Slider is updated, e.g. a Form.

Mixes In:
  - module:util.ColorMixin
Source:
  - visual/Slider.js, line 20
To Do:
  - check that parameters are valid, e.g. ticks are an array of numbers, etc.
  - readOnly
  - complete setters, for instance setTicks should change this._isCategorical
  - flesh out the skin approach

### Extends

- module:visual.VisualStim

### Members

#### contains

Determine whether an object is inside the bounding box of the stimulus.

Overrides:
  - module:visual.VisualStim#contains
Source:
  - visual/VisualStim.js, line 184

#### getRating

Get the current value of the rating.

Source:
  - visual/Slider.js, line 306

#### getRT

Get the response time of the most recent change to the rating.

Source:
  - visual/Slider.js, line 326

#### refresh

Force a refresh of the stimulus.

Overrides:
  - module:visual.VisualStim#refresh
Source:
  - visual/Slider.js, line 254

#### reset

Reset the slider.

Source:
  - visual/Slider.js, line 267

#### setMarkerPos

Setter for the markerPos attribute.

Setting markerPos changes the visible position of the marker to the specified rating but does not change the actual rating returned by the slider.

Source:
  - visual/Slider.js, line 377

#### setOri

Setter for the orientation attribute.

Inherited From:
  - module:visual.VisualStim#setOri
Source:
  - visual/VisualStim.js, line 133

#### setPos

Setter for the position attribute.

Inherited From:
  - module:visual.VisualStim#setPos
Source:
  - visual/VisualStim.js, line 161

#### setRating

Setter for the rating attribute.

Setting the rating does not change the visible position of the marker.

Source:
  - visual/Slider.js, line 402

#### setReadOnly

Setter for the readOnly attribute.

Read-only sliders are half-opaque and do not provide responses.

Source:
  - visual/Slider.js, line 346

#### setSize

Setter for the size attribute.

Inherited From:
  - module:visual.VisualStim#setSize
Source:
  - visual/VisualStim.js, line 105

#### (readonly) Shape :Symbol

Shape of the marker and of the ticks.

##### Type:

- Symbol

Source:
  - visual/Slider.js, line 1467

#### (readonly) Skin :any

Skin.

##### Type:

- any

Source:
  - visual/Slider.js, line 1499

#### (readonly) Style :Symbol

Styles.

##### Type:

- Symbol

Source:
  - visual/Slider.js, line 1482

### Methods

#### (protected) _estimateBoundingBox()

Estimate the bounding box.

Overrides:
  - module:visual.VisualStim#_estimateBoundingBox
Source:
  - visual/Slider.js, line 466

#### (protected) _onChange(withPixiopt, withBoundingBoxopt) → {function}

Generate a callback that prepares updates to the stimulus. This is typically called in the constructor of a stimulus, when attributes are added with _addAttribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`withPixi` | boolean | <optional> | false | whether or not the PIXI representation must also be updated
`withBoundingBox` | boolean | <optional> | false | whether or not to immediately estimate the bounding box

Inherited From:
  - module:visual.VisualStim#_onChange
Source:
  - visual/VisualStim.js, line 266

##### Returns:

Type
  function

#### (protected) _sanitizeAttributes()

Sanitize the slider attributes: check for attribute conflicts, missing values, etc.

Source:
  - visual/Slider.js, line 601

#### isMarkerDragging() → {boolean}

Query whether or not the marker is currently being dragged.

Source:
  - visual/Slider.js, line 293

##### Returns:

whether or not the marker is being dragged

Type
  boolean

#### recordRating(rating, responseTimeopt, logopt)

Set the current rating.

Setting the rating does also change the visible position of the marker.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`rating` | number |  |  | the rating
`responseTime` | number | <optional> |  | the reaction time
`log` | boolean | <optional> | false | whether of not to log

Source:
  - visual/Slider.js, line 677