angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
http://angular-ui.github.io/ui-scroll/demo/
MIT License
326 stars 107 forks source link

Height doesn't reset correctly on scroll top #248

Closed irimescucosmin closed 3 years ago

irimescucosmin commented 3 years ago

Untitled `

Colorway Colorway Description Season Action
{{colorway.colorway}}
;` ![jsconfig](https://user-images.githubusercontent.com/17571229/89630295-7276a800-d89f-11ea-95d8-0211a472d71e.png)
dhilt commented 3 years ago

@irimescucosmin There maybe some conflict between thead and tbody, I guess. I would look at this more precisely if you could provide a minimal repro (by forking, for example, this stackblitz demo).

irimescucosmin commented 3 years ago

Hi @dhilt

Here you are an example of how I use it. https://stackblitz.com/edit/ui-scroll-heigh-error?file=app.js You have to try a few time because not always happening.

Thanks

dhilt commented 3 years ago

@irimescucosmin Well, I see the problem with negative indexes. You have limited datasource started with index 0. Datasource get per your implementation periodically tries to fetch negative indexes when you are at the top position. The fix is to restrict indexes at the datasource.get level and cut off negative values before fetch (slice in your case):

datasource.get = (index, count, callback) => {
  var last = index + count; // last index to fetch
  index = Math.max(0, index); // index can't be less than o
  count = last - index; // new count
  ...
  callback(...);
}

Also, it seems reasonable to fix the minimal index value as the start index value which is 1 by default:

    <div ui-scroll="item in datasource" buffer-size="5" start-index="0">
      ...
    </div>
irimescucosmin commented 3 years ago

@dhilt thanks, you solved a big problem for me.