You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see in the video, when scrolling up or down, once the list item reaches the start/end of the overflow area, the top/bottom box-shadow is cut off. The box-shadow is used to indicate the focused list item (fake focus indication in this case, since the input field at the top always has focus when using the keyboard).
The code to get this behaviour looks like this:
scrollToItem(index: number,position: 'start'|'center'|'end'|'nearest'='nearest'): void{constscroller=this.renderRoot.querySelector('.items')asLitVirtualizer,{ bottom, top }=scroller.getBoundingClientRect(),item=this.getItemAtIndex(index),{bottom: itemBottom=0,top: itemTop=0}=item?.getBoundingClientRect()||{};if(!item){// Item can't be found in the DOM, likely because it's not there yetscroller.scrollToIndex(index,position);}elseif(itemBottom>=bottom){// Item is below the bottom of the listscroller.scrollToIndex(index,'end');}elseif(itemTop<=top){// Item is above the top of the listscroller.scrollToIndex(index,'start');}}
Screen.Recording.2022-05-23.at.09.11.34.mov
As you can see in the video, when scrolling up or down, once the list item reaches the start/end of the overflow area, the top/bottom box-shadow is cut off. The
box-shadow
is used to indicate the focused list item (fake focus indication in this case, since the input field at the top always has focus when using the keyboard).The code to get this behaviour looks like this:
Perhaps similar to
scrollIntoView
, support the second parameter being an object? https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewscroller.scrollToIndex(index, { position: 'end', offset: 4 });
?The text was updated successfully, but these errors were encountered: