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 05 - 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) {
e.target.style.visibility = '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.

4 Comments

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."
src: http://stackoverflow.com/questions/1687296/what-is-dom-event-delegation

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:
http://share.framerjs.com/h978dv8ruwwd/

Read the entire post on Facebook