Hi! I’m trying to get a lighbox to pop up when the user scrolls past a specific anchor point. I feel like there is a simple solution to this but am having trouble. Can anybody help me with this?
Hi Anna
You’re right, there is quite a simple solution to this. You can use an anchor and add either the onViewPortEnter / onViewPortLeave event handlers to it depending on your preference, and then simply add this code in between the brackets:
import wixWindow from 'wix-window'; // add this to the top of your page
wixWindow.openLightbox("LightboxName"); // add this in between the ancor's curly brackets
Best of luck!
Tiaan
If you find that a lightbox ends up not working as well for your needs and you need a pinned container instead, I’d recommend using the viewportEnter/leave of some larger element in your page or you could purposefully place some invisible box/strip for this purpose. I find this much better if what you want is your container to pop up when you scroll to the bottom and back to the top of your page!
Awesome, thank you both so much!
I tried this solution but when I preview the page and scroll past the anchor point nothing happens … Is there anything specific I can do to troubleshoot?
@rsmith
Combine the given CODE by Tiaan and the knowledge which you can get in the following link…
https://russian-dima.wixsite.com/meinewebsite/reading-position
Attention onto the red-line in the example! (it could also be an ANCHOR)!