API / geotoolkit / responsive / ResponsiveStyle / ResponsiveStyle
responsive.ResponsiveStyle.ResponsiveStyle
Defines behavior of responsive nodes.
Example
// Function as condition
import {ResponsiveStyle} from '@int/geotoolkit/responsive/ResponsiveStyle';
const rules = [
{
'condition': (node) => return node.getBounds().getWidth() < 500 && node.getBounds().getWidth() > 200,
'properties': {
'z': {
'annotationsize': 0
}
}
}];
const style = new ResponsiveStyle({
'rules': rules
});Example
// Object as condition
const rules = [
{
'condition': {
'maxWidth': 500,
'maxHeight': 500
},
'properties': {
'z': {
'annotationsize': 0
}
}
}];
const style = new ResponsiveStyle({
'rules': rules
});Example
// Expressions as condition
const rules = [
{
'condition': 'node => width(node) < 500 || height(node) < 500',
'properties': {
'z': {
'annotationsize': 0
}
}
}];
const style = new ResponsiveStyle({
'rules': rules
});Example
// CSS style as properties
const rules = [
{
'condition': (node) => node.getBounds().getWidth() < 500 && node.getBounds().getWidth() > 200,
'css': [
'.Grid { ',
' visible: false;',
'}',
'.CrossPlot {',
'z-annotationsize: 0;',
'x-annotationsize: 0;',
'y-annotationsize: 0;',
'}'
].join('\n')
}];↳
ResponsiveStyle
Constructors
Methods
Methods
▸ apply(node, target?): ResponsiveStyle
Apply rules for the current node
| Name | Type | Description |
|---|---|---|
node | Node | current instance of the node |
Optional target | Node | current instance of the target node |
▸ clone(): Style
All inheritors should implement copy constructor or provide custom implementation for this method
this
▸ Protected copyConstructor(src): ResponsiveStyle
copy constructor
| Name | Type | Description |
|---|---|---|
src | ResponsiveStyle | Source to copy from |
▸ dispose(): void
Dispose.
void
▸ getClassName(): string
string
▸ getProperties(): OptionsOut
Gets all the properties pertaining to this object
▸ getTimeStamp(): number
Gets time stamp
number
timeStamp
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
▸ invalidate(): ResponsiveStyle
notify the node that the style is invalidated
this
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): ResponsiveStyle
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | Style | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): ResponsiveStyle
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: ResponsiveStyle, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): ResponsiveStyle
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: ResponsiveStyle, args: EventMap[E]) => void | to be called |
this
▸ setProperties(properties?): ResponsiveStyle
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | An object containing the properties to set |
▸ setSilent(bool, force?): ResponsiveStyle
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
Optional force | boolean | true if parent should be invalidated immediately |
this
▸ supportsEvent(event): boolean
Check if style should be applied for the current event
| Name | Type | Description |
|---|---|---|
event | string | event to check |
boolean
▸ updateTimeStamp(silent?): ResponsiveStyle
Update time stamp to indicate that style has been changed.
| Name | Type | Description |
|---|---|---|
Optional silent | boolean | silent mode. If this parameter equals to true then style doesn't send invalidate event |
this
▸ Static fromObject(object): ResponsiveStyle
Create or get responsive style from object
| Name | Type | Description |
|---|---|---|
object | Options | ResponsiveStyle | object can be in format of constructor ResponsiveStyle |
responsive style
▸ Static getClassName(): string
string
▸ Static isStyleNotificationEnabled(): boolean
Return status of the global notification for all styles.
boolean