If I sort the array of galleryImages, the new sort order is not reflected in the gallery.
Calling .sort on the array has no effect, but calling .splice works as expected.
How can I rearrange the images in the array and have it be reflected in the gallery at runtime?
I am actually using an array of a custom type that extends NgxGalleryImage and contains a property that I'm using to set the sort order. So it's actually more like:
// [images] input of <ngx-gallery/> tag points to this.property.galleryItems,
// which extends NgxGalleryImage
// sortingArray contains an array of integers used to determine the new sort order
// of the property.galleryItems array
this.property.galleryItems.sort((a, b) => {
let aIndex = this.sortingArray.indexOf(a.galleryItemID);
let bIndex = this.sortingArray.indexOf(b.galleryItemID);
if (aIndex < bIndex) {
return -1;
} else if (aIndex == bIndex) {
return 0;
}
return 1;
});
And this does not rearrange the images in the gallery as I would expect it to.
If I sort the array of galleryImages, the new sort order is not reflected in the gallery.
Calling .sort on the array has no effect, but calling .splice works as expected.
How can I rearrange the images in the array and have it be reflected in the gallery at runtime?
I am actually using an array of a custom type that extends NgxGalleryImage and contains a property that I'm using to set the sort order. So it's actually more like:
And this does not rearrange the images in the gallery as I would expect it to.