Slider

Extends Widget

A widget representing a numeric value as an movable indicator on a horizontal line.

Import this type with “const {Slider} = require('tabris');

Android iOS
Slider on Android Slider on iOS

Properties

maximum

Type: number, default: 100

The maximum value.

minimum

Type: number, default: 0

The minimum value.

selection

Type: number, default: 0

The actual value.

tintColor

Type: Color

The color used to display the current selection.

Events

maximumChanged

Fired when the maximum property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: number The new value of maximum.

minimumChanged

Fired when the minimum property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: number The new value of minimum.

select

Fired when the selection property is changed by the user.

Event Parameters

  • target: this The widget the event was fired on.

  • selection: number The new value of selection.

selectionChanged

Fired when the selection property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: number The new value of selection.

tintColorChanged

Fired when the tintColor property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: Color The new value of tintColor.

Example

  1. const {Slider, TextView, ui} = require('tabris');
  2. // Create a slider with a selection handler
  3. let textView = new TextView({
  4. left: 10, right: 10, top: '30%',
  5. alignment: 'center',
  6. font: '22px sans-serif',
  7. text: '50'
  8. }).appendTo(ui.contentView);
  9. new Slider({
  10. left: 50, top: [textView, 20], right: 50,
  11. minimum: -50,
  12. selection: 50,
  13. maximum: 150
  14. }).on('selectionChanged', ({value}) => textView.text = value)
  15. .appendTo(ui.contentView);

See also

原文:

https://youjingyu.github.io/Tabris-Documention/?folderName=widgets&pageName=Slider.html