Make the scroll position updated as soon as possible to the correct deferred value
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
co-authored by
Antonio Scandurra
parent
927e0db750
commit
f57ff1c660
@@ -95,6 +95,7 @@ impl UniformListScrollHandle {
|
|||||||
} else if item_bottom > scroll_top + state.list_height {
|
} else if item_bottom > scroll_top + state.list_height {
|
||||||
scroll_offset.y = -(item_bottom - state.list_height);
|
scroll_offset.y = -(item_bottom - state.list_height);
|
||||||
}
|
}
|
||||||
|
self.deferred_scroll_to_item = None;
|
||||||
} else {
|
} else {
|
||||||
self.deferred_scroll_to_item = Some(ix);
|
self.deferred_scroll_to_item = Some(ix);
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,6 @@ impl UniformListScrollHandle {
|
|||||||
if let Some(state) = &*self.state.borrow() {
|
if let Some(state) = &*self.state.borrow() {
|
||||||
-state.scroll_offset.borrow().y
|
-state.scroll_offset.borrow().y
|
||||||
} else {
|
} else {
|
||||||
self.deferred_scroll_to_item = Some(0);
|
|
||||||
Pixels::ZERO
|
Pixels::ZERO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,12 +241,15 @@ impl Element for UniformList {
|
|||||||
scroll_handle.state.borrow_mut().replace(ScrollHandleState {
|
scroll_handle.state.borrow_mut().replace(ScrollHandleState {
|
||||||
item_height,
|
item_height,
|
||||||
list_height: padded_bounds.size.height,
|
list_height: padded_bounds.size.height,
|
||||||
scroll_offset: shared_scroll_offset,
|
scroll_offset: shared_scroll_offset.clone(),
|
||||||
});
|
});
|
||||||
if let Some(ix) = scroll_handle.deferred_scroll_to_item.take() {
|
if let Some(scroll_handle) = self.scroll_handle.as_mut() {
|
||||||
dbg!("@@@@");
|
if scroll_handle.state.borrow().is_some() {
|
||||||
scroll_handle.scroll_to_item(ix);
|
if let Some(ix) = scroll_handle.deferred_scroll_to_item.take() {
|
||||||
cx.notify();
|
scroll_handle.scroll_to_item(ix);
|
||||||
|
scroll_offset = *shared_scroll_offset.borrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user