Skip to content

Commit

Permalink
Merge pull request #2046 from Skyscanner/bellagio/LMN-1597-fix-image-…
Browse files Browse the repository at this point in the history
…grid-scroll-position

[LMN1597][BpkImageGalleryGrid] Fix switching reset scroll view position
  • Loading branch information
marianeum authored Aug 15, 2024
2 parents 9a801db + 577047e commit a2586cc
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,26 @@ struct ImageGalleryGridContentView<Categories: View, GridImageView: View, Slides
header
VStack(spacing: 12) {
categories()
TwoRowGrid(
items: gridImages
) { item, index in
item.content()
.aspectRatio(contentMode: .fill)
.clipped()
.frame(height: itemHeightInGrid)
.accessibilityAddTraits(.isButton)
.onTapGesture {
imageTapped(selectedCategoryIndex, index)
imageIndexInCategory = index
isSlideshowPresented.toggle()
}
ScrollViewReader { proxy in
TwoRowGrid(
items: gridImages
) { item, index in
item.content()
.aspectRatio(contentMode: .fill)
.clipped()
.frame(height: itemHeightInGrid)
.accessibilityAddTraits(.isButton)
.onTapGesture {
imageTapped(selectedCategoryIndex, index)
imageIndexInCategory = index
isSlideshowPresented.toggle()
}
.onChange(of: selectedCategoryIndex) { _ in
proxy.scrollTo(0)
}
}
.padding(.horizontal, .lg)
}
.padding(.horizontal, .lg)
}
.padding(.bottom, .base)
}
Expand Down

0 comments on commit a2586cc

Please sign in to comment.