pub struct ScrollAnchor<K> {
pub key: K,
pub offset_in_viewport: u64,
}Expand description
A scroll anchor that can be used to preserve visual position across data changes.
Typical use cases:
- chat/timeline “prepend” (load older messages above) without content jumping
- any reorder/replace where you want the viewport to stay anchored to an item identity
The adapter is responsible for providing a stable key and a key_to_index lookup when
applying the anchor.
Fields§
§key: K§offset_in_viewport: u64The distance from the anchor item’s start to the viewport’s scroll offset.
Trait Implementations§
Source§impl<K: Clone> Clone for ScrollAnchor<K>
impl<K: Clone> Clone for ScrollAnchor<K>
Source§fn clone(&self) -> ScrollAnchor<K>
fn clone(&self) -> ScrollAnchor<K>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<K: Debug> Debug for ScrollAnchor<K>
impl<K: Debug> Debug for ScrollAnchor<K>
Source§impl<'de, K> Deserialize<'de> for ScrollAnchor<K>where
K: Deserialize<'de>,
impl<'de, K> Deserialize<'de> for ScrollAnchor<K>where
K: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K: PartialEq> PartialEq for ScrollAnchor<K>
impl<K: PartialEq> PartialEq for ScrollAnchor<K>
Source§impl<K> Serialize for ScrollAnchor<K>where
K: Serialize,
impl<K> Serialize for ScrollAnchor<K>where
K: Serialize,
impl<K: Eq> Eq for ScrollAnchor<K>
impl<K> StructuralPartialEq for ScrollAnchor<K>
Auto Trait Implementations§
impl<K> Freeze for ScrollAnchor<K>where
K: Freeze,
impl<K> RefUnwindSafe for ScrollAnchor<K>where
K: RefUnwindSafe,
impl<K> Send for ScrollAnchor<K>where
K: Send,
impl<K> Sync for ScrollAnchor<K>where
K: Sync,
impl<K> Unpin for ScrollAnchor<K>where
K: Unpin,
impl<K> UnwindSafe for ScrollAnchor<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more