ScrollKit icon indicating copy to clipboard operation
ScrollKit copied to clipboard

How to set initial offset for ScrollViewWithOffsetTracking

Open codetiger opened this issue 2 years ago • 3 comments

I am using ScrollViewWithOffsetTracking and want to set the initial scroll offset to a different value than 0. How can I do this?

codetiger avatar Mar 28 '24 06:03 codetiger

Hi @codetiger

I haven't tried, but can you wrap it in a ScrollViewReader and use that proxy to scroll?

danielsaidi avatar Mar 28 '24 07:03 danielsaidi

scroll to a particular id is possible, but I want to scroll to an offset. I am using this for a sliding ruler where user can select a floating point number

codetiger avatar Mar 28 '24 09:03 codetiger

There's no built-in support for that, but I'd be happy to merge anything you come up with :)

danielsaidi avatar Mar 28 '24 11:03 danielsaidi

@codetiger I have given this some thought, and think you should be able to wrap the ScrollViewWithOffsetTracking in a ScrollViewReader, and use its reader to control the position, or add a scrollPosition modifier to the content view, if you're using later iOS versions.

Since there are native ways to do this now, I will not add this to the SDK, and will thus close this issue. If you miss some feature in the SDK to be able to use it, please let me know.

danielsaidi avatar Oct 05 '24 09:10 danielsaidi