hello friends,
I'm having an issue with a button with delayed display, I tried to use the SETTIMEOUT and DELAY function but I couldn't get it to work well, and they never work.
I finally tried to create a Lightbox with a button included and a timer,
but I know that Lightbox needs a Trigger and so I would like this trigger to be the Play button in wix video. (this is a 30min sales page)
how would you go about solving this issue?
how to make this thing work?
import {local} from 'wix-storage'; import wixWindow from 'wix-window'; $w.onReady (function () { if(!local.getItem("firtTimePopupShown")) { setTimeout(function() => {wixWindow.openLightbox("np")},240000); local.setItem("firstTimePopupShown"), "yes"); } } export function videoPlayer1_play(event) { if $w('#videoPlayer1') (params) { }/ }
So just to clarify for setTimeOut. This function waits a predefined amount of time and then runs the function you specified. So your code is currently saying set a time out for 240,000 ms (ie. 4 minutes) and then open this Lightbox named "np". If this is what you want then it should work.
I don't think you can handle the event click for the play button on a video but you could use https://www.wix.com/velo/reference/$w/videoplayer/onplay instead. Note that this is the onPlay event not the play event. Also you'll want to make sure you're setting your event handlers as described here: https://support.wix.com/en/article/velo-reacting-to-user-actions-using-events
If you get that setup right then you can put the code inside your onReady block in this event handler and you should be good to go.
Also it would be more proper to set like this since you're checking for true/false values.
local.setItem("firstTimePopupShown"), true);