Class HoverTrigger

HoverTrigger allows you to run actions when the user hovers overs a target element, and undo those actions when their pointing device moves off the target. On touch devices it acts just like PressTrigger.


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

  • Arguments: none
  • Additional trigger options: none
    • target: A string element specification. See getReferenceElement.
    • prevent-default: boolean
    • prevent-select: boolean

Add classes active and hovered when the user hovers over the element, remove them otherwise.

<div data-lisn-on-hover="@add-class=active,hovered"></div>

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

<div class="lisn-on-press--@add-class=active,hovered"></div>

Play the animations on the element 1000ms after the first time the user hovers over the element it.

<div data-lisn-on-hover="@animate +once +delay=1000"></div>

Add class hovered the first time the user hovers over the element, and play the animations on the element while the user is hovering over the element with a delay of 100ms, reverse the animations as soon as the user mouse leaves the element.

<div data-lisn-on-click="@add-class=hovered +once ;
@animate +do-delay=100"
></div>

When the user hovers over the next element with class box 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 their pointing device (or finger) moves off the reference element.

<div data-lisn-on-hover="@add-class=c1,c2 @enable=my-trigger +target=next.box"
data-lisn-on-run="@show +id=my-trigger"
></div>
<div class="box"></div>

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

<div data-lisn-on-hover="@add-class=c1,c2 @enable=my-trigger +target=next-box"
data-lisn-on-run="@show +id=my-trigger"
></div>
<div data-lisn-ref="box"></div>

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: () => PointerTriggerConfig

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.