I did everything exactly as listed above and it does not work. I am very new at this so please bare with me. Before adding the code do I add any “events” under the anchor or logo properties?
If you use the code I posted above, here’s no need to add event listeners via the property panel.
It’s hard to say what the problem is, but maybe you put the anchor too high (so it’s always in the viewport?
The code should work just fine, maybe you’ve implemented it in a wrong way, please share your code with us, add some screenshots of the elements, collections, etc …
In summary:
I have an image of my logo placed in the top left side (in the header) of my homepage; labeled logo and set to collapsed on load. Further down, I have set an anchor; labeled anchor1 .
With the following code added under page NOT site:
$w.onReady(() => {
$w( “#anchor1” ).onViewportEnter(event => {
$w( “#logo” ).expand();
})
$w( “#anchor1” ).onViewportLeave(event => {
$w( “#logo” ).collapse();
})
})