So, you ask for a list of mutations and then, for each mutation you repeat
exactly the same procedure which is not related to the mutation you are
currently at.
Why are you iterating over mutations?

Regards,
Witold Szczerba

On Wed, Mar 1, 2017 at 4:59 PM, 'Rupert Smith' via Elm Discuss <
elm-discuss@googlegroups.com> wrote:

> On Tuesday, February 28, 2017 at 10:54:56 PM UTC, Witold Szczerba wrote:
>>
>> I have used MutationObserver, so in Elm all I have to do is to add a
>> specific class and custom event handler, so there is no need to track it by
>> "id". The mutation observer is attached at the top node of the Elm app.
>> This works OK so far.
>>
>
> When looking for nodes that have may have been resized, I found it helpful
> just to scan from the top of the document for the 'watch-resize' class.
> This is because the mutation may occur nested within some div that I am
> interested in. The div is not in 'addedNodes' on the mutation, and it isn't
> always the 'target' either, sometimes its the parent of the target,
> sometimes the parent.parent and so on.
>
>         const topElement = document.getElementById("jtrial");
>
>         const observer = new MutationObserver(mutations => {
>           mutations.forEach(mutation => {
>             $(topElement).find('.watch-resize').each(function () {
>               console.log("found node with .watch-resize class.");
>               console.log($(this));
>
>               var result = {
>                   id: $(this).context.id,
>                   height: $(this).context.clientHeight,
>                   width: $(this).context.clientWidth
>               };
>
>               app.ports.mutation.send(result);
>             });
>           });
>         });
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to