-
-
Notifications
You must be signed in to change notification settings - Fork 20
Scroller position to top after fetching new data and unexpected scroll on mobile #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
public datasource = new Datasource({
}); |
html template ...... |
Can you please provide a minimal example on https://stackblitz.com/edit/ngx-ui-scroll-3-angular-17 ? Thank you |
Please check it here Thanks |
Thank you! You dont need to reload inside datasource get. Also you dont need to create new items in datasource get. You just read from a datasource there. Heres your example working with less code: https://stackblitz.com/edit/ngx-ui-scroll-3-angular-17-2fj141ke?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.css |
Yes thanks |
The datasource get only fetches data. You read from a source, till the source has no new data. I think we have the xy-Problem here. Can you tell me, what you want to do in the bigger picture? |
I want to show my items of the cart where i receive the cart items from the server i get the first 20 than when list gets to the end i want to data to fetched but i have some unexpected scrolls |
Thx! In the datasource get method you implement the simple data fetching logic. something like this:
there you fetch count cart items from the server, beginning at index. the server responds with the requested count items. if there are no more cart items, or not enough to fill out count, the server responds with an empty array [] or fewer items then count. eg just 2 instead of 20 like: [{id: x},{id: y}] the scroller is intelligent enough to register, there are no more items and stops. let me know if it works for you |
what is the signature of your server data fetching code? can it use the parameters count and index, or does it need pagination like page 1,2,3? |
i use pagination like 1,2,3,... |
is the scroller height sensitive i have some unexpected scroll when the new items are changed in the dom |
also i get an array of objects form the server dose this works in this case i can't change the logic on the server |
the scroller works really well with variable heights. this library is truly wonderful - only the beginning may be hard :o) for pagination you can transform the count and index to pages, look at this example: `get: async (index: number, limit: number) => { const startPage: number = Math.floor(startIndex / pageSize); const start: number = startIndex - startPage * pageSize; const requests: Promise[] = []; for (let i = startPage; i <= endPage; i++) { return Promise.all(requests).then((res: any) => {
}); |
there are some errors how should i modify it the call to server for items
} |
the items model |
Can you provide a full example? |
it seems you're loading the data seperate, but you need to load the data in the datasource get function |
the pagination is fine now but https://github.com/user-attachments/assets/0e2a4cfe-896f-4f72-8bb9-e8b923a8f1ad |
Jeah! Please show me your datasource code |
public datasource = new Datasource({ iam getting all data at once and than passing to the scroller when scroller dose the job of replacing the items in the dom happens that thing |
public datasource = new Datasource({
}); this is with pagination |
Can you isolate the scroller and test again? I think you may have multiple elements with margin before oder after the scroller, so its jumping. also the elements inside the scroller should not have margins (use paddings instead) |
okay i will let you know |
I want to implement ui-scroller with parent scroll to handle my cart in my app where the max number of elements is 1000 ,how can i implement pagination and to fix scroller scrolling to the first element, and in mobile the ui isn't optimized @dhilt
The text was updated successfully, but these errors were encountered: