Setup
Add the InViewTrigger dependency to your module and place the following nodes in your screen's OnReady event in this exact order:
Step 1 — Define your callbacks
Add a JavaScript node (OnReady) and define the global functions that InViewTrigger will call:
window.OnElementEnter = function() { $actions.YourClientAction();};
window.OnElementLeave = function() { $actions.YourOtherClientAction();};
Replace YourClientAction and YourOtherClientAction with the actual names of your Client Actions.
Step 2 — Invoke InViewTrigger
Add the InViewTrigger action after the JavaScript node and configure its parameters.For elements taller than the viewport, avoid using 1.0 as it will never trigger.
Important notes
Observing multiple elements
To observe multiple elements at once, define all callbacks in a single JavaScript node and then invoke InViewTrigger once per element, all after the JavaScript node.
Each InViewTrigger registers its own independent observer, so multiple instances on the same screen will not interfere with each other.
For a live preview please visit the Demo.