LitElement infinite scroll reposition issue

dork

I'm creating a POC for a LitElement infinite scroller that limits the DOM count of the list. The component is based on this one: https://medium.com/walmartglobaltech/infinite-scrolling-the-right-way-11b098a08815

My POC is here: https://stackblitz.com/edit/lit-element-infinite-scroller-poc

The item positioning is achieved by adjusting the paddings and updating the list item content when the IntersectionObserver is triggered.

When the component is scrolled really fast from top to bottom, it works fine. When you slow down the scroll, it sometimes adds a padding before reaching the threshold of the IntersectionObserver. As for scrolling from bottom to top, it always behaves like that regardless of whether you scroll fast or slowly.

I'm guessing it's a timing issue but I can't pinpoint where exactly.

HerberthObregon

As Dipen says, I feel like _getNewTopItemIndex can be optimized but really if you see lit-visualizer it's quite laborious to do this implementation.

I recommend you not to reinvent the wheel, you can use lit-virtualizer

https://www.npmjs.com/package/lit-virtualizer

try with

npm i lit-virtualizer

I think you need something else you can collaborate with the project (https://github.com/polymerlabs/uni-virtualizer)

Example:

render() {
        return html`
            <lit-virtualizer
              .scrollTarget=${window}
              .items=${this.data}
              .renderItem=${(contact) => html`
                <div><b>${contact.name}</b>: ${contact.phone}</div>
              `}>
            </lit-virtualizer>
        `;
    }

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

React Native Infinite Scroll

分類Dev

Infinite scroll in RecyclerView

分類Dev

Ionic 4 Infinite Scroll

分類Dev

Parse HTML Infinite Scroll

分類Dev

Prolog infinite loop issue

分類Dev

Codeigniter:Ajax infinite scroll with filter

分類Dev

RecyclerView infinite scroll in both directions

分類Dev

Infinite scroll with angularfire2

分類Dev

iCarousel infinite scroll and index reset

分類Dev

CSS | Overflow Scroll Issue

分類Dev

Horizontal scroll issue

分類Dev

Scraping an infinite scroll page stops without scrolling

分類Dev

Laravel 5 Paginate + Infinite Scroll jQuery

分類Dev

Infinite Scroll jQuery&Laravel 5 Paginate

分類Dev

How to make godot infinite background scroll

分類Dev

Flutter infinite scroll always reset the view

分類Dev

Tumblr infinite scroll not working with jquery script

分類Dev

Nested ng-repeats, filter and infinite scroll

分類Dev

JQuery Add Class On Scroll Issue

分類Dev

Foundation - Off Canvas Scroll Issue

分類Dev

Cant resolve an issue with an infinite loop in a chat app

分類Dev

Issue in implementing infinite retry in kafka consumer

分類Dev

infinite while loop with screen click issue

分類Dev

Jquery not working after page one on website with Infinite Scroll

分類Dev

Position fixed and overflow-y:scroll issue

分類Dev

CSS "position:fixed" scroll text overlapping issue

分類Dev

Flutter searchbar layout issue BoxConstraints forces an infinite width

分類Dev

Getting Infinite Loop Issue. Process Terminated due to StackOverflowException?

分類Dev

Canvas with negative z-index issue on scroll in Chrome