Using custom functions in custom animations

I’m attempting to create a “look-at” behaviour for items, where the items follow the cursor when inside their shared container.

I know how to do the calculations for the required rotation, but I can’t get the javascript atan (or atan2) functions to be recognised in the interactions editor.

Is there a trick to this? Alternatively, it is possible to call a manually defined js function from interactions?

At the moment I’m at the stage of simply setting the rotation to a fixed value (e.g. atan(0.5)) but it does nothing.

If you want to trigger a JS function with Pinegrow Interaction you can use “Interaction > Call function (on complete)”. Just type in the name of your function.

2 Likes

By Jove. It works!

For others who have the same question, adding a few more details to @Riccarcharias posting.

The option is where you are choosing to add a parameter when in Edit Animation > Edit Transition > Add parameter. Down the bottom of the list of options is Interactions > Call function. I went with the “on update” option.

In there, you insert the name of your function (without parenthesis). It will call your function with parameters of the target element and the progress [0…0.1]. In your function you can make any changes you desire.

2 Likes