loading... Pacem JS

Listen to Element events

PacemEventProxyElement listens to a specific event on a specific target (element) and eases a reactions to that event.

<pacem-event-proxy target="#button1" event="click" on-emit="console.log($event.originalEvent.target.innerText)"></pacem-event-proxy>

PacemEventProxyElement can target native DOM elements (not only custom elements).

In the following example a PacemEventProxyElement listens to some click event on a div element that contains a button.
The click event triggered by the button will eventually bubble up to the div and then intercepted by our component.

PacemEventProxyElement is useful in case of bubbling events that are not directly dispatched by the target element itself.

Listen to Window events as well

PacemEventProxyElement may listen to Window events as well.
Set the target attribute to magic string $window for this use-case.

<pacem-event-proxy target="$window" event="focus" on-emit="console.log($event.originalEvent.target + ' focused.')"></pacem-event-proxy>