-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) Implement gallery looping #207
base: dev
Are you sure you want to change the base?
Conversation
After cloning the gitcode also gives bounce effect for image looping , because Bounce effect is mentioned in show(index,gallery) function in baguttebox.js file... instead use the below code in show(index.gallery) function -> if index is less than 0 - showfirstimage and if index is greater than array length - showlastimage. function show(index, gallery) {
if (!isOverlayVisible && index >= 0 && index < gallery.length) {
prepareOverlay(gallery, options);
showOverlay(index);
return true;
}
if (index < 0) {
if (options.animation) {
showLastImage();
}
return false;
}
if (index >= imagesElements.length) {
if (options.animation) {
showFirstImage(0);
}
return false;
}
currentIndex = index;
loadImage(currentIndex, function() {
preloadNext(currentIndex);
preloadPrev(currentIndex);
});
updateOffset();
if(options.onChange) {
options.onChange(currentIndex, imagesElements.length);
}
return true;
} |
@kavithakavithap your code doesn't make sense. I've tested my solution on several devices and it works fine. Make sure you enable the looping with I'm waiting for more people to confirm that. |
Adding loop: true has had no effect. Do I need a newer version of baguetteBox? I am using version 1.8.1. |
@mountaineer25 you need to clone the repository and check out to the branch |
I've tested this and it works, but the effect is not as nice as I would have hoped. When moving from the last image to the first the "image roll" very quickly rolls back through all the images to the first one. Sort of like a quick rewind. And vice versa in the other direction. It would be nicer if the animation went directly to the first/last image without moving through every image in between. |
@Pont sorry, that's currently out of scope, it would require too many changes in the code. |
So the looping is some kind of 'rewind' effect? click image 1 image 1 displays image 1 displays no rewinding effect just a round and round we go 1 2 3 4 1 2 3 4 even increments. |
@ketonik as mentioned in my previous comment, that's currently not possible. |
2>feimos, that deserves unhappy face 😢 Donation of $$, can help to create the magic? |
Here is one called colorbox, this all can do continuous cycling 123,123, maybe can check his code and get some clues to make work same in Baguettebox? loop true If false, will disable the ability to loop back to the beginning of the group when on the last element. |
Sorry, to implement that I'd have to rewrite a significant part of the script, the current logic underneath does not support it what basically means creating v2. I'm very busy now and can't address it anytime soon. |
65f6b6e
to
6e8fc24
Compare
Is this something that will be released soon? Or does anyone know a workaround? |
@rubenberendsen easy work around to have seemingly infinite looping for your gallery is just add all the photos again below with anchor tags a few times. This won't slow your page as it's just links. and as there is no content in the a tags, they'll be invisible.
|
To enable gallery looping set the
loop
option