Hey guys,
I need to add a effect in show and hide functions but my code not working.
Here’s my code:
$w.onReady( function () {
$w(“#gallery1”).hide();$w(“#gallery2”).hide();
});
export function button1_click() {
if ( $w(“#gallery1”).hidden ) {
$w(“#gallery1”).show (‘slide’);
}
else {
$w(“gallery1”).hide();
}
}
export function button2_click() {
if ( $w(“#gallery2”).hidden ) {
$w(“#gallery2”).show (‘slide’);
}
else {
$w(“gallery1”).hide();
}
}
Hi, Raniere Figueiredo !
- Check for errors? Probably, instead $w(“gallery1”).hide(); it is necessary so $w(“#gallery1”).hide();
- For example, if your user presses the button in Europe, but the servers with the site are in California, you need time to react with the gallery. This is not in your code . The code exits before the end of the effect.
The manual says: “The hide () function hides the element and returns a Promise that is resolved when the effect is complete and the element’s hidden property has been set to true.” Gallery - Velo API Reference - Wix.com
Try this a sample code when the effect is done:
$w("#myElement").hide("fade")
.then( ( ) => {
console.log("Done with fade");
} );
Good luck!