Class CheckTrigger

CheckTrigger allows you to run actions when the user checks a target checkbox input element, and undo those actions when they uncheck the checkbox.


To use with auto-widgets (HTML API), see registerTrigger for the specification.

Add classes active and checked when the user checks the checkbox, remove them when unchecked.

<input type="checkbox" data-lisn-on-check="@add-class: active,checked"/>

As above, but using a CSS class instead of data attribute:

<input type="checkbox" class="lisn-on-check--@add-class: active,checked"/>

Play the animations on the element each time the user checks the next element with class checkbox (do nothing when it's unchecked).

<div data-lisn-on-check="@animate +one-way +target=next.checkbox"></div>
<input type="checkbox" class="checkbox"/>

Add class used the first time the user checks the next element with class checkbox, and play or reverse the animations 200ms after each time the user toggles the reference checkbox.

<div data-lisn-on-check="@add-class: used +once ;
@animate +delay=200 +target=next.checkbox"
></div>
<input type="checkbox" class="checkbox"/>

When the user checks the next element with class checkbox then add classes c1 and c2 to the element (that the trigger is defined on) and enable trigger my-trigger defined on this same element; undo all of that when the user unchecks the reference checkbox.

<div data-lisn-on-check="@add-class: c1,c2 @enable: my-trigger +target=next.checkbox"
data-lisn-on-run="@show +id=my-trigger"
></div>
<input type="checkbox" class="checkbox"/>

As above, but using data-lisn-ref attribute instead of class selector.

<div data-lisn-on-check="@add-class: c1,c2 @enable: my-trigger +target=next-checkbox"
data-lisn-on-run="@show +id=my-trigger"
></div>
<input type="checkbox" data-lisn-ref="checkbox"/>

Hierarchy (View Summary)

Methods

Constructors

Properties

destroy: () => Promise<void>

Undoes all modifications to the element and returns it to its original state.

You will need to recreate it if you want to enable its functionality again.

disable: () => Promise<void>

Disables the functionality of the widget. What this means is specific to each widget.

enable: () => Promise<void>

Re-enables the functionality of the widget. What this means is specific to each widget.

getActions: () => Action[]

Returns the trigger's actions.

getConfig: () => CheckTriggerConfig

Returns the trigger config.

getElement: () => Element

Returns the element passed to the widget constructor.

isDestroyed: () => boolean

Returns true if the widget is destroyed.

isDisabled: () => boolean

Returns true if the widget is currently disabled.

onDestroy: (handler: WidgetHandler) => void

The given handler will be called when the widget is destroyed.

onDisable: (handler: WidgetHandler) => void

The given handler will be called when the widget is disabled.

onEnable: (handler: WidgetHandler) => void

The given handler will be called when the widget is enabled.

reverse: () => Promise<void>

"Undo"es all the Actions linked to the trigger.

run: () => Promise<void>

"Do"es all the Actions linked to the trigger.

toggle: () => Promise<void>

"Toggle"s all the Actions linked to the trigger.

toggleEnable: () => Promise<void>

Re-enables the widget if disabled, otherwise disables it.