I have created a gallery page for my neighborhood to visit where the images are categorized by the neighborhood event (eg July 4th, Easter, etc). Users select the event and I dynamically load the gallery via a table with pictures from that event. This all works wonderfully as a general rule. However, I noticed when I go from event to event, the currentIndex remains unchanged from the previous event rather than getting reset to 0. As long as the currentIndex is a valid index for the new list of pictures that are loaded, this is not a large problem. It just means that the visitor may not be looking at the first image of that new event.
However, if I am looking at the last picture of one event, then reload the gallery with the new event that has less images, no thumbnails are selected and I get a blank image for the new event that requires the visitor to select a thumbnail or click on the Previous/Next navigation arrows.
The issue is more pronounced if one event has many photos where the visitor has scrolled the thumbnails to the right. In that case, when changing to an event with fewer photos, the thumbnails are still scrolled to the right from the previous event, leaving a confusing display. If there are far less images in the next event, it may be that there are no images nor any thumbnails showing at all.
This object has the ability to GET the index, but there doesn’t seem to be the ability to SET a gallery index. To me, when I reload the items array, either the object should automatically reset the index or I should be allowed to reset the index programmatically. What am I missing?
Example :
In the example above, the last image for the event is being viewed.
However, when I change the event with less images:
There is no image selected because the index is set to a value larger than the gallery.items array of the new event.
From a programmatic standpoint, prior to loading the new list of images to the gallery, I clear out the gallery items array in hope that it would reset the index ($w("#gallery).items = ;).
Alas, it does not.
Anyone have any insight on how to overcome this?
This feels like a bug. However, I will start by assuming this is my issue…