Hello! I’ve been searching everywhere, but cant find solution to my problem ( which shouldn’t be that hard to pull off). I want to change my images with different buttons. If i have one window with several images and several buttons( say button1,button2 and button3) over my image. When i click button2 my image changes to image2 etc. I send picture.
Would be very greatful for the anwser because there seems to be no such topic ( witch is strange)
One more question is it possible to make transition more smooth? I tryed to add animation but it only works when the image appear when you load the page.
If you use an image, you can’t make an animation, but maybe you’ll want to use a slider gallery instead , to the gallery items and to switch them. It’s a different code. See: https://www.wix.com/corvid/reference/$w.Gallery.html#items
@yisrael-wix Thanks for quick answer and the effect code. I dont really understand whre i should put it and how it works with the context of my codel. This is my code atm:
Hmm, that works but strange. When i click on the button my image fades out, and then i have to click again for the image to show (fade in). I tryed to delete fade out but i didnt help. How is it possible to solve?
@valentin1995 Sorry . The hide() and show() functions return Promises - I always forget about that - and you can only do the show() when the hide is done.
Something like this:
$w.onReady(() => {
$w("#button1, #button2, #button3").onClick(event => {
$w("#image1").hide("fade").
.then( ( ) => {
let src;
switch(event.target.id) {
case "button1":
src = "xxxxxxx.jpg";//use the image source
break;
case "button2":
src = "yyyyyyyy.jpg";//use the image source
break;
case "button3":
src = "zzzzz.jpg";//use the image source
break;
}
$w("#image1").src = src;
$w("#image1").show("fade");
} );
})
})
Not tested, but that should give the right idea how to handle the Promise returned from hide().
@yisrael-wix I tryed, it says TypeError: $w(…).hide(…).$w is not a function. Can you possibly know why? p.s. Very much appreciated that you give your time to my problem
my code: