@@ -188,7 +188,6 @@ angular.module('ui.scroll', [])
188
188
buffer .eof = false
189
189
buffer .remove (buffer .length - overage, buffer .length )
190
190
buffer .next -= overage
191
- viewport .adjustPadding ()
192
191
193
192
viewport .shouldLoadTop = ->
194
193
! buffer .bof && (viewport .topDataPos () > viewport .topVisiblePos () - bufferPadding ())
@@ -208,8 +207,6 @@ angular.module('ui.scroll', [])
208
207
buffer .bof = false
209
208
buffer .remove (0 , overage)
210
209
buffer .first += overage
211
- viewport .adjustPadding ()
212
- viewport .adjustScrollTop { height : heightIncrement, clipTop : true }
213
210
214
211
calculateAverageItemHeight = () ->
215
212
viewport .averageItemHeight = 0
@@ -227,11 +224,17 @@ angular.module('ui.scroll', [])
227
224
viewport .adjustScrollTop = (options ) ->
228
225
return if not options or not options .height
229
226
# edge case 1, scroll up from the very top position
230
- if options .prepend and viewport .scrollTop () < options .height
231
- viewport .scrollTop viewport .scrollTop () + options .height
227
+ if options .prepend
228
+ paddingHeight = topPadding .height () - options .height
229
+ if paddingHeight >= 0
230
+ topPadding .height paddingHeight
231
+ else
232
+ topPadding .height 0
233
+ viewport .scrollTop viewport .scrollTop () - paddingHeight
234
+
232
235
# edge case 2, scroll down from the very bottom position
233
- if options .clipTop and options .height - bottomPadding .height () > 0
234
- viewport .scrollTop viewport .scrollTop () + options .height - bottomPadding .height ()
236
+ # if options.clipTop and options.height - bottomPadding.height() > 0
237
+ # viewport.scrollTop viewport.scrollTop() + options.height - bottomPadding.height()
235
238
236
239
viewport
237
240
@@ -432,12 +435,12 @@ angular.module('ui.scroll', [])
432
435
keepFetching = insertWrapperContent (wrapper) || keepFetching
433
436
wrapper .op = ' none'
434
437
adjustPaddingSettings .height += wrapper .element .height ()
438
+ viewport .adjustScrollTop (adjustPaddingSettings)
435
439
436
440
# re-index the buffer
437
441
item .scope .$index = buffer .first + i for item,i in buffer
438
442
439
443
viewport .adjustPadding ()
440
- viewport .adjustScrollTop (adjustPaddingSettings)
441
444
442
445
# schedule another adjustBuffer after animation completion
443
446
if (promises .length )
0 commit comments