Skip to content
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

Map view jumps to old fraction when scrolled #44

Open
stevengharris opened this issue Dec 16, 2024 · 2 comments
Open

Map view jumps to old fraction when scrolled #44

stevengharris opened this issue Dec 16, 2024 · 2 comments

Comments

@stevengharris
Copy link
Owner

I'm evaluating this library and I found a problem when trying to put a Map (SwiftUI) into the Top view on a VSplit. I've reproduced it by adding a Map to the Demo sample simpleAdjustable Code below. Once I move the map (or zoom) the Split is resized back to an original position instead of retaining where the User left it. Is there a known workaround to resolve this? Video below.

case .simpleAdjustable:
                Split(
                    primary: {
                        Map(coordinateRegion: $region, annotationItems: annotations) {
                            MapPin(coordinate: $0.coordinate)
                        }
                    },
                    secondary: { Color.red }
                )
                .styling(color: .yellow)
                .layout(demo.holders[0].layout)
                .hide(demo.holders[0].hide)

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2024-12-16.at.12.41.17.mp4

Other supporting code:

@State var region: MKCoordinateRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.09, longitude: -95.71), latitudinalMeters: Measurement(value: 15, unit: UnitLength.miles).converted(to: .meters).value, longitudinalMeters: Measurement(value: 15, unit: UnitLength.miles).converted(to: .meters).value)
let annotations: [City] = [ ]
struct City: Identifiable {
    let id = UUID()
    let name: String
    let coordinate: CLLocationCoordinate2D
}

Originally posted by @kylepinionseb in #43

@stevengharris
Copy link
Owner Author

It turns out that a fix I made to allow the Split view to respond to changes in the split fraction caused this. I was a little worried at the time that there might be side-effects, but I could not find any. I believe you can fix the issue by removing or commenting out the following ~line 102 in Split.swift:

.onChange(of: fraction.value) { new in constrainedFraction = new }

I will have to follow-up with a fix that works in that case without screwing up yours. Unless you're also trying to set the fraction as discussed in #29, it should not impact you to remove this. Thanks.

@kylepinionseb
Copy link

Yes, disabling that line for me works. Thanks for the quick tip! I was experimenting with fraction, and it doesn't seem to cause a problem using that for an initial setting, and then the User can adjust and all seems well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants