1.0.6 • Published 6 years ago

@ircam/gui-components v1.0.6

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
6 years ago

GUI-Components

Set of simple gui components (to be extended)

Install

npm install [--save] @ircam/gui-components

Available Components

Usage

import { Slider} from '@ircam/gui-components';

const slider = new Slider({
  mode: 'jump',
  container: '#container',
  default: 0.6,
  markers: [0.5],
  callback: (value) => console.log(value),
});

API

gui-components

gui-components~Slider

Versatile canvas based slider.

Kind: inner class of gui-components

new Slider(options)

ParamTypeDefaultDescription
optionsObjectOverride default parameters.
options.mode'jump' | 'proportionnal' | 'handle''jump'Mode of the slider: - in 'jump' mode, the value is changed on 'touchstart' or 'mousedown', and on move. - in 'proportionnal' mode, the value is updated relatively to move. - in 'handle' mode, the slider can be grabbed only around its value.
options.callbackfunctionCallback to be executed when the value of the slider changes.
options.widthNumber200Width of the slider.
options.heightNumber30Height of the slider.
options.minNumber0Minimum value.
options.maxNumber1Maximum value.
options.stepNumber0.01Step between each consecutive values.
options.defaultNumber0Default value.
options.containerString | Element'body'CSS Selector or DOM element in which inserting the slider.
options.backgroundColorString'#464646'Background color of the slider.
options.foregroundColorString'steelblue'Foreground color of the slider.
options.orientation'horizontal' | 'vertical''horizontal'Orientation of the slider.
options.markersArray[]List of values where markers should be displayed on the slider.
options.showHandleBooleantrueIn 'handle' mode, define if the draggable should be show or not.
options.handleSizeNumber20Size of the draggable zone.
options.handleColorString'rgba(255, 255, 255, 0.7)'Color of the draggable zone (when showHandle is true).

Example

import { Slider} from 'gui-components';

const slider = new Slider({
  mode: 'jump',
  container: '#container',
  default: 0.6,
  markers: [0.5],
  callback: (value) => console.log(value),
});

slider.value : Number

Current value of the slider.

Kind: instance property of Slider

slider.reset()

Reset the slider to its default value.

Kind: instance method of Slider

slider.resize(width, height)

Resize the slider.

Kind: instance method of Slider

ParamTypeDescription
widthNumberNew width of the slider.
heightNumberNew height of the slider.

License

BSD-3-Clause