I’m building a chat section. I’ve managed to work out most aspects of the chat experience. I understand how to retrieve all my data when I reach the top of the screen, and I know how to set up the variables and related components. The real challenge I’m facing is maintaining the correct scroll position when scrolling upwards.
From what I’ve gathered, the efficient way to handle scroll position after updating the content is to:
- Save the current scroll position
- Calculate the new content height
- Determine the difference between old and new heights
- Use these measurements to compute where I was previously in the scroll position
I’ve implemented this approach, and it functions well on Windows. However, I’m encountering platform-specific issues:
- On Safari, my screen briefly flashes white, forcing me to scroll again to make the content reappear.
- On Android, the scroll position isn’t as precise as it should be, and I’m not entirely sure why.
I’m curious if anyone else has run into similar scrolling problems and how you managed to resolve them?