This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Lukas Imrich
Posted Jan 22 - Read on Facebook

Does framer has something similar to - target - "A reference to the object that dispatched the event" ?

To be able to do something like this,

function hide(e) { = 'hidden';

list.addEventListener('click', hide, false);

Here is my piece of code, in which I am looking how to reference layer that emitted an event. Target is giving me "just" reference to div element.


Amit Kaplinsky

Hey Lukas Imrich did you find any solution for this issue ?

Jordan Robert Dobson

Look at the docs. You get event and layer from the click event.

layer.on Events.Click, (event, targetLayer) ->

print event, targetLayer

Koen Bok

Also, `this` in the function is the target layer.

Jordan Robert Dobson

this or @ or layer I believe are the same things.

Lukas Imrich

Sorry for not being clear.

DOM allows event propagation:
"The event is dispatched to its target EventTarget and any event listeners found there are triggered. Bubbling events will then trigger any additional event listeners found by following the EventTarget's parent chain upward, checking for any event listeners registered on each successive EventTarget. This upward propagation will continue up to and including the Document."

The question should rather be:
Is event propagation happening in framerjs layer logic?

In other words, I want to listen to an event on superLayer, and get noticed whenever the event occurs on any of its child layers.

That is why I was asking how to find the target layer, even if the target layer is a child of the layer which listens to the event.

Here I put together an example demonstrating exactly that:

Read the entire post on Facebook