| 3723 | } |
| 3724 | |
| 3725 | void ViewNode::setMaintainScrollAnchor(bool maintain) { |
| 3726 | auto& scrollState = getOrCreateScrollState(); |
| 3727 | scrollState.setMaintainScrollAnchor(maintain); |
| 3728 | } |
| 3729 | |
| 3730 | void ViewNode::setPreserveScrollPosition(bool preserve) { |
| 3731 | auto& scrollState = getOrCreateScrollState(); |
| 3732 | scrollState.setPreserveScrollPosition(preserve); |
| 3733 | // Capture the anchor immediately on enable, from the current (still valid, pre-insertion) |
| 3734 | // layout. Otherwise the anchor stays empty until the next scroll/layout pass; if that pass is |
| 3735 | // a content insertion (live message / forward page), Step 1 in updateScrollState would be |
| 3736 | // skipped (no anchor) and the viewport would jump before the anchor is first recorded. |
| 3737 | if (preserve && _calculatedFrame.height > 0.0f) { |
| 3738 | refreshPreserveAnchor( |
| 3739 | this, scrollState, scrollState.getDirectionAgnosticContentOffset().y, _calculatedFrame.height); |
| 3740 | } |
| 3741 | } |
| 3742 | |
| 3743 | template<typename F> |
| 3744 | void ViewNode::updateViewportExtension(F&& handler) { |
| 3745 | auto& scrollState = getOrCreateScrollState(); |
nothing calls this directly
no test coverage detected