0

I have this view where I'd like to insert an image inside a scroll view so when the user zooms in they can scroll through the zoomed in photo, however, I'd like to add a double tap functionality which zooms in and sets the position of the picture where the user tapped. I have successfully been able to zoom the picture in and allow scrolling, it just zooms in to the exact centre of the image each time, instead of where they double tapped. I have the location data via a CGPoint

 GeometryReader { proxy in
        ScrollView([.vertical, .horizontal], showsIndicators: false){
            image?
                .resizable()
                .aspectRatio(contentMode: .fit)
                .onTapGesture(count: 2) { location in
                    print(location)
                    // set scroll view position here
                    onImageDoubleTapped(locationTapped: location)
                }
                .gesture(zoomGesture)
                .frame(width: proxy.size.width * max(minZoomScale, zoomScale))
                .frame(maxHeight: .infinity)
        }
    }
Nathan
  • 1,393
  • 1
  • 9
  • 40

0 Answers0