GradientSlider.getColorByValue

Syntax

getColorByValue(value);

Parameters

value. Value of the slider that allows color selection.

Description

The getColorByValue method returns color of the slider that allows color selection by specified value.

Comments

The method returns value of the PP.Color property.

Example

To execute the example, the page must contain the GradientSlider component named slider (see Example of Creating the GradientSlider Component). Get and display color of the slider with the value 0.75, handle the AddClick, ItemColorChanged and RemoveClick events, change color of the slider with the index 0:

// Get the slider color with the 0.75 value
var color = slider.getColorByValue(0.75);
// Display obtained color value
console.log("Color of obtained slider: R:" + color.getR() + " G:" + color.getR() + " B:" + color.getB());
// Handle the AddClick event
slider.AddClick.add(function (sender, args, timeout) {
    console.log("The AddClick event is initialized")
});
// handle the ItemColorChanged event
slider.ItemColorChanged.add(function (sender, args, timeout) {
    console.log("The ItemColorChanged event is fired")
});
// Handle the RemoveClick event
slider.RemoveClick.add(function (sender, args, timeout) {
    console.log("The RemoveClick event is fired")
});
// Change color of the slider with the 0 index
slider.getItemByIndex(0).setColor("#FFF000");

Click Add and Delete buttons one after another. The component slider will be added and deleted.

After executing the example color of the slider with the index 0 changes:

The browser console displays color value for the slider with specified value and messages informing that handled events have been fired:

Slider color: R:255 G:255 B:0

ItemColorChanged event initialized

AddClick event initialized

The RemoveClick event is initialized

 

See also:

 GradientSlider