Skip to content

Commit

Permalink
Scroll bounce based on image size (#646)
Browse files Browse the repository at this point in the history
* Scroll bounce based on image size
  • Loading branch information
mohamede1945 authored Aug 17, 2024
1 parent 777228c commit 17e4f71
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion UI/NoorUI/Features/Quran/AdaptiveImageScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct AdaptiveImageScrollView<Header: View, Footer: View>: View {

public var body: some View {
GeometryReader { geometry in
ScrollView {
scrollView {
VStack(spacing: 0) {
header
.onSizeChange { headerSize = $0 }
Expand Down Expand Up @@ -80,6 +80,16 @@ public struct AdaptiveImageScrollView<Header: View, Footer: View>: View {
private let onScaleChange: (WordFrameScale) -> Void
private let onGlobalFrameChange: (CGRect) -> Void

@ViewBuilder
private func scrollView(@ViewBuilder content: () -> some View) -> some View {
if #available(iOS 16.4, *) {
ScrollView(content: content)
.scrollBounceBehavior(.basedOnSize)
} else {
ScrollView(content: content)
}
}

private func imageGeometrySize(from geometry: GeometryProxy) -> CGSize {
CGSize(
width: geometry.size.width - readableInsets.leading - readableInsets.trailing,
Expand Down

0 comments on commit 17e4f71

Please sign in to comment.