new Slider(parent, props)
Slider element. Additional callbacks can be added with the onChange method. This class focuses on the specific properties of the Slider component. Since it inherits from Accessor_A, all basic properties (e.g., height, width) are available but documented in the Accessor_A part.
| Name | Type | Description |
|---|---|---|
parent | HTMLElement | HTML element that is going to be the parent of the component |
props | TComponents. |
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();Extends
Members
activeColor :string
Sets the color of active track of the Slider component.
- string
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.activeColor = 'red';descrLabel :string
Sets the content of description label.
- string
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.descrLabel = 'hello world';displayLabel :boolean
Sets the property to true to display the description lanel in the Slider component.
- boolean
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.displayLabel = 'hello world';displayTicks :boolean
Sets to true to display step ticks in the Slider component.
- boolean
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.displayTicks = false;displayValue :boolean
Sets the property to true to display the value lanel in the Slider component.
- boolean
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.displayValue = false;inactiveColor :string
Sets the color of inactive track of the Slider component.
- string
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.inactiveColor = 'red';max :number
Sets the maximum value of the slidr
- number
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.max = 100;min :number
Sets the minimum value of the Slider component range.
- number
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set max value.
slider.min = 10;onPointerDown :function
Sets the pointer down event handler for the Slider component.
- The handler can either be a string representing a function to be executed or a function itself.
- If you are using an arrow function, like
()=>{}, thethisproperty of the scope may not refer to the slider object. - If you are using string assignment to define code execution, the string should contain
only the body of the code (executable statements), not a complete function declaration. Therefore, including function keywords like function or async function is incorrect.
- Correct (Statements Only):
xx.onPointerDown = "console.log('Action done.');" - Incorrect (Function Declaration):
xx.onPointerDown = "function() { console.log('Action done.'); }"
- function
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Example 1: Using a string as the handler:
slider.onPointerDown = "console.log('state changed', this.text);";// Example 2: Using a arrow function as the handler:
// Note that the `this` context will not refer to the slider object
slider.onPointerDown = () => { console.log('state changed', slider.text); };// Example 3: Using a common function as the handler:
slider.onPointerDown = async function() {
console.log('state changed', this.text);
};onPointerRelease :function
Sets the pointer release event handler for the Slider component. The handler can either be a string representing a function to be executed or a function itself.
- If you are using an arrow function, like
()=>{}, thethisproperty of the scope may not refer to the slider object. - If you are using string assignment to define code execution, the string should contain
only the body of the code (executable statements), not a complete function declaration. Therefore, including function keywords like function or async function is incorrect.
- Correct (Statements Only):
xx.onPointerRelease = "console.log('Action done.');" - Incorrect (Function Declaration):
xx.onPointerRelease = "function() { console.log('Action done.'); }"
- function
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Example 1: Using a string as the handler:
slider.onPointerRelease = "console.log('state changed', this.text);";// Example 2: Using a arrow function as the handler:
// Note that the `this` context will not refer to the slider object
slider.onPointerRelease = () => { console.log('state changed', slider.text); };// Example 3: Using a common function as the handler:
slider.onPointerRelease = async function() {
console.log('state changed', this.text);
};value :number
Sets the value of the Slider component.
- number
- Source
const slider = new TComponents.Slider(document.body, {
position: 'absolute',
zIndex: 1000,
max:200,
min:50,
value:100,
});
// Render the component.
slider.render();
// Set value.
slider.value = 20;Methods
(protected) defaultProps() → {TComponents.SliderProps}
Returns the default values of class properties (excluding parent properties).
- Overrides
- Source
- Type:
- TComponents.
SliderProps
markup() → {string}
Generates the markup for the Slider component.
- Overrides
- Source
HTML markup string
- Type:
- string
onInit() → {void}
Initializes the Slider component.
- Overrides
- Source
- Type:
- void
onRender() → {void}
Renders the Slider component.
- Overrides
- Source
Throws an error if rendering fails.
- Type
- Error
- Type:
- void
(static) loadCssClassFromString(css) → {void}
Add css properties to the component
| Name | Type | Description |
|---|---|---|
css | string | The css string to be loaded into style tag |
- Source
- Type:
- void
TComponents.Slider.loadCssClassFromString(`
.tc-slider {
height: inherit;
}`
);