Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing ScrollPercent and ScrollIndex properties
Opening a PR for this to start to get feedback. Some context... One important feature missing from v1 of layout scrolling is the ability to set scroll offset programmatically. Currently you can only change scroll offset manually (ie, by physically dragging the scroll content). We discussed a few properties to allow this, but the most obvious ones were scroll percent (0-100 dynamically computed based on the viewport and content size) and scroll index (scrolling to a specific child item by index). One roadblock to implementing these is that they need to work seamlessly with manual scrolling, so if you set scroll index to 3, then manually scroll, then set scroll index to 5, the scroll offset value should move from whatever the **_current_** offset is, not the last scroll index value. In addition, if you set scroll percentage, then scroll index, then manually scroll, etc, the offset should move smoothly between all scenarios. The approach this PR takes is to add core properties for scroll percent and scroll index, but these core properties do not themselves store values. They get and set values on the scroll offset. This way, they will always be able to get the current scroll offset, do a computation to convert to percent/index, and as a result move smoothly to the next state. Having to recompute the the percent/index values on the fly is one of the cons of this approach. An additional thing to note is that the percent and index values will always align to the same offset (which I think is ok). A caveat to this approach is that when manual scrolling occurs, in the riv file, we need to move to a state with no keys for scroll percent or scroll index so that we don't animate from the current state's keyed value accidentally. There will need to be some updates to the core generator to add support for this (the first commit in this PR only has the base class implementation generated by hand). Also, if we decide this is a good approach, it needs to be ported to the C++ runtime. Open to feedback and suggestions if we think there is a more effective way. https://github.com/user-attachments/assets/f116f2b7-a292-4dd5-8c23-221ad3b821d3 Diffs= a95cbfa147 Implementing ScrollPercent and ScrollIndex properties (#8886)
- Loading branch information