Last updated

API / geotoolkit / responsive / ResponsiveStyle / ResponsiveStyle

Class: 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 &amp;&amp; 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 &amp;&amp; node.getBounds().getWidth() > 200,
'css': [
'.Grid { ',
' visible: false;',
'}',
'.CrossPlot {',
'z-annotationsize: 0;',
'x-annotationsize: 0;',
'y-annotationsize: 0;',
'}'
].join('\n')
}];

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new ResponsiveStyle(options)

new ResponsiveStyle(options?)

Parameters

Name Type
Optional optionsOptions

Overrides

Style.constructor

Methods

apply

apply(node, target?): ResponsiveStyle

Apply rules for the current node

Parameters

Name Type Description
nodeNodecurrent instance of the node
Optional targetNodecurrent instance of the target node

Returns

ResponsiveStyle


clone

clone(): Style

All inheritors should implement copy constructor or provide custom implementation for this method

Returns

Style

this

Inherited from

Style.clone


copyConstructor

Protected copyConstructor(src): ResponsiveStyle

copy constructor

Parameters

Name Type Description
srcResponsiveStyleSource to copy from

Returns

ResponsiveStyle

Overrides

Style.copyConstructor


dispose

dispose(): void

Dispose.

Returns

void

Inherited from

Style.dispose


getClassName

getClassName(): string

Returns

string

Inherited from

Style.getClassName


getProperties

getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut

Overrides

Style.getProperties


getTimeStamp

getTimeStamp(): number

Gets time stamp

Returns

number

timeStamp

Inherited from

Style.getTimeStamp


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

Style.hasEventListener


invalidate

invalidate(): ResponsiveStyle

notify the node that the style is invalidated

Returns

ResponsiveStyle

this

Inherited from

Style.invalidate


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

Style.isDisposed


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

Style.isSilent


notify

notify<E>(type, source, args?): ResponsiveStyle

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceStyleof the event
Optional argsEventMap[E]arguments of the event

Returns

ResponsiveStyle

this

Inherited from

Style.notify


off

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.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: ResponsiveStyle, args: EventMap[E]) => voidfunction to be called

Returns

ResponsiveStyle

this

Inherited from

Style.off


on

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.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: ResponsiveStyle, args: EventMap[E]) => voidto be called

Returns

ResponsiveStyle

this

Inherited from

Style.on


setProperties

setProperties(properties?): ResponsiveStyle

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsAn object containing the properties to set

Returns

ResponsiveStyle

Overrides

Style.setProperties


setSilent

setSilent(bool, force?): ResponsiveStyle

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode
Optional forcebooleantrue if parent should be invalidated immediately

Returns

ResponsiveStyle

this

Inherited from

Style.setSilent


supportsEvent

supportsEvent(event): boolean

Check if style should be applied for the current event

Parameters

Name Type Description
eventstringevent to check

Returns

boolean


updateTimeStamp

updateTimeStamp(silent?): ResponsiveStyle

Update time stamp to indicate that style has been changed.

Parameters

Name Type Description
Optional silentbooleansilent mode. If this parameter equals to true then style doesn't send invalidate event

Returns

ResponsiveStyle

this

Inherited from

Style.updateTimeStamp


fromObject

Static fromObject(object): ResponsiveStyle

Create or get responsive style from object

Parameters

Name Type Description
objectOptions | ResponsiveStyleobject can be in format of constructor ResponsiveStyle

Returns

ResponsiveStyle

responsive style


getClassName

Static getClassName(): string

Returns

string

Inherited from

Style.getClassName


isStyleNotificationEnabled

Static isStyleNotificationEnabled(): boolean

Return status of the global notification for all styles.

Returns

boolean

Inherited from

Style.isStyleNotificationEnabled