Index with decimal...
priandsf opened this issue · comments
Not sure if this is a bug or not, but it sometimes calls the datasource with a non integer number, like 19.4 (and count=10). In that case, should we round it down to 19 but then, should we increment the count as well?
Thanks for the issue! Having analysed it shallowly, I would say following. This
Line 154 in 05896d8
and that
Line 164 in 05896d8
are the only places where
index
are being passed to the datasource.get
. The buffer.next
and buffer.first
are being maintained by src/modules/buffer.js and there are only ++
, --
, =1
and =startIndex
operations. So I'm wondering how did you get this non-decimal index
value...
Maybe I'm missing something, so it needs to be debugged, what code is responsible for breaking index
integrity. If you want me to debug, the best option would be to make a plunkr/jsfiddle/stackblitz demo reproducing the issue.
Thank Denis. I need to debug through it which I'll do this week-end. It seems that the issue happens after a reload, where we changed the data source and the #of rows. The debugger shows, for example. buffer.first, maxIndex, minIndex all set a the value like "22.6". I'll try to find out how this happens
Your screenshot makes me think about
ui-scroll/src/modules/buffer.js
Lines 7 to 17 in 05896d8
So, speaking of reload, I would recommend to investigate startIndex
argument value...
Anyway, I think it is a good idea to protect "start-index" attribute and Adapter.reload(startIndex)
argument from non-decimal values right in the ui-scroll code. I see it's not safe now, it is fully under user responsibility, which could be improved. Putting enhancement label.
Yep this is I actually did and this is the culprit. So nothing on your side, unless you might want to make it robust calling Math.floor().
Thanks for your help, this is an awesone library!
angular-ui-scroll v1.7.3 has been released, it includes "start-index" attribute and Adapter.reload method argument pre-validation