Here is the quick tip I would like to share (not a question).
I had a couple people emailed me personally from the Wix forum asking this question. I thought I post it here in case people are searching for the answer.
I understand the Lightbox API maybe a bit hard to find. It is in the wix-window API. Here you have it:
And to close the lightbox, use this:
wixWindow.lightbox.close();
Hi Keawe,
Thanks for your reply and please accept my apology for late reply due to time zone difference,
I have now replaced my lightbox with a content box and used show & hide codes to make the content box show when mouse is on button and hide when mouse is away from button but I need to give site visitors âtimeâ when they are on the lightbox to select an item from within the lightbox, is it possible ? and what is the code ?
I think this approach may work. Here is the pseudo code follows by the simple code.
Pseudo:
On top of the code page, create a variable (call it myTimer) to hold a setTimeOut pointer.
In your onMouseOut handler, Use setTimeout to delay the content box to disappear in x second.
That will give your user enough time to go inside before the content box (you still call it lightbox) disappear.
Clear the timer using the variable myTimer when the user selects an item. That way the user can spend all the time they want to make selection decision.
When the userâs mouse is out of the content box, reset the timer to make it disappear.
Here is the simple code (I tested it. It works)
let myTimer;
$w.onReady(function () {
// write some code here
});
export function button_mouseIn() {
clearTimeout(myTimer);
$w(â#containerâ).show();
}
export function button_mouseOut() {
myTimer = setTimeout(()=>{
$w(â#containerâ).hide();
},1500);
}
export function container_mouseIn() {
clearTimeout(myTimer);
}
export function container_mouseOut() {
myTimer = setTimeout(()=>{
$w(â#containerâ).hide();
},1500);
}
Note:
â Make sure the myTimer is on top of your page. Because it needs to be accessed by all the handlers.
â The 1500 is just my test. You can use whatever wait time you want.
Hope that works for you
P.S. I am not part of Wix support team. I am just some random guy who like to pitch in to help the Wix Code community. I will try to get back to you whenever I have spare time. But I canât promise I will reply in time.
Also, you have "import window from âwix-windowsâ; " on top of each export functionâŚ
Hope you are really not doing that. You should only import something on top of the page once only.
Just thought I mention it. Maybe you already know.
Hi Keawe,
I placed the code but when the mouse is inside the container the setTimeout delay doesnât work :
export function container_mouseIn() {
clearTimeout(myTimer);
}
export function container_mouseOut() {
myTimer = setTimeout(()=>{
$w(â#containerâ).hide();
},1500);
}
and to show you the code I placed in full is as follows :
let myTimer;
$w.onReady(function () {
// write some code here
});
export function button18_onmouseIn() {
clearTimeout(myTimer);
$w(â#box3â).show();
}
export function button18_onmouseOut() {
myTimer = setTimeout(()=>{
$w(â#box3â).hide();
},1500);
}
export function box3_onmouseIn() {
clearTimeout(myTimer);
}
export function box3_onmouseOut() {
myTimer = setTimeout(()=>{
$w(â#box3â).hide();
},1500);
}
Did you check to make sure all the handlers are named correctly for each element? For example: Do you have the function names correct correctly for the box3 onmouseIn?
I will screen record what I have done and post it here to show you after on today.
Thanks for your reply, should I remove any other codes from the page ? if no then where should I place your code (on the top of the page or on the bottom of the page ?
and what does the sentence "write some code here " mean ?
Hi Keawe,
Please find attached the video showing the website page (button and content box) , codes added and result happening, kindly advise what might be wrong
Thanks
Here this the problem I found. See the image here. Your box3 onMouseIn and onMouseOut handlers are empty. Thatâs why they donât work! You need to put the correct function names in there. Just like you did for the buttons.