UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

OnDrag Preview not centering on selected drag item but on parent view

Forums > SwiftUI

Hi All,

Back again with another question - things are moving on, at least.

Slowly figuring out Drag n Drop but have run into a problem. When I select my Drag target the view I'm given to drag around is the entirety of the top level view; it does, however, center on the selected target.

So I've replaced that with a Preview item instead which works but it now centres that on the parent view, as can be seen in the image below. I've highlighted the drag target with the red circle and the green blob in the middle is the preview it's given me. I tried using offset but that shifts the rectangle within the centred frame itself.

Screenshot-2022-03-02-at-13-14-38.png

Anyone got any suggestions how I can get around that?

Thanks in advance,

Jes

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.