- Source:
- Mixes In:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.gradient |
Object | Boolean | Gradient definition for the background.
Keys are ints or floats as string corresponding to the widgets scale.
Values are valid css color strings like |
||
options.background |
String | Boolean |
<optional> |
"#000000"
|
Background color if no gradient is used.
Values are valid css color strings like |
Gradient provides a function to set the background of a
DOM element to a CSS gradient according to a Range.
If the element to draw on is a CANVAS
, the canvas API is used
for drawing.
Methods
drawGradient(element, gradientopt, fallbackopt, rangeopt) → {string}
- Source:
- Mixes In:
This function generates a string from a given
gradient object to set as a CSS background for a DOM element.
If element is given, the function automatically sets the
background. If gradient is omitted, the gradient is taken from
options. Fallback is used if no gradient can be created.
If fallback is omitted, options.background
is used. If no range
is set Gradient assumes that the implementing instance has
Range functionality.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
element |
DOMNode | The DOM node to apply the gradient to. |
||
gradient |
Object |
<optional> |
this.options.gradient
|
Gradient definition for the background, e.g. |
fallback |
string |
<optional> |
this.options.background
|
If no gradient can be applied, use this as background color string. |
range |
Range |
<optional> |
this
|
If a specific range is set, it is used for the calculations. If not, we expect the widget itself provides Ranged functionality. |
Fires:
Returns:
A string to be used as background CSS.
- Type
- string
Events
backgroundchanged
- Source:
Is fired when the gradient was created.
Parameters:
Name | Type | Description |
---|---|---|
element |
HTMLElement | The element which background has changed. |
background |
string | The background of the element as CSS color string. |