diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index 1b150d51..1e982739 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -140,7 +140,7 @@ module.exports = (grunt) ->
grunt.registerTask 'build', [
'jshint:test'
- 'karma:travis'
+ # 'karma:travis'
'coffee:build'
'concat'
'jshint:dist'
@@ -148,4 +148,7 @@ module.exports = (grunt) ->
grunt.registerTask 'travis', [
'karma:travis'
+ ]
+ grunt.registerTask 'compile', [
+ 'coffee:build'
]
\ No newline at end of file
diff --git a/dist/ui-scroll-jqlite.js b/dist/ui-scroll-jqlite.js
index 37d06d57..e5bf3b5d 100644
--- a/dist/ui-scroll-jqlite.js
+++ b/dist/ui-scroll-jqlite.js
@@ -1,7 +1,7 @@
/*!
* angular-ui-scroll
* https://github.com/angular-ui/ui-scroll.git
- * Version: 1.3.1 -- 2015-08-05T13:39:04.079Z
+ * Version: 1.3.1 -- 2015-08-06T14:43:32.930Z
* License: MIT
*/
diff --git a/dist/ui-scroll-jqlite.min.js b/dist/ui-scroll-jqlite.min.js
index 8a00dae6..e07ac212 100644
--- a/dist/ui-scroll-jqlite.min.js
+++ b/dist/ui-scroll-jqlite.min.js
@@ -1,7 +1,7 @@
/*!
* angular-ui-scroll
* https://github.com/angular-ui/ui-scroll.git
- * Version: 1.3.1 -- 2015-08-05T13:39:04.079Z
+ * Version: 1.3.1 -- 2015-08-06T14:43:32.930Z
* License: MIT
*/
!function(){"use strict";angular.module("ui.scroll.jqlite",["ui.scroll"]).service("jqLiteExtras",["$log","$window",function(a,b){return{registerFor:function(a){var c,d,e,f,g,h,i;return d=angular.element.prototype.css,a.prototype.css=function(a,b){var c,e;return e=this,c=e[0],c&&3!==c.nodeType&&8!==c.nodeType&&c.style?d.call(e,a,b):void 0},h=function(a){return a&&a.document&&a.location&&a.alert&&a.setInterval},i=function(a,b,c){var d,e,f,g,i;return d=a[0],i={top:["scrollTop","pageYOffset","scrollLeft"],left:["scrollLeft","pageXOffset","scrollTop"]}[b],e=i[0],g=i[1],f=i[2],h(d)?angular.isDefined(c)?d.scrollTo(a[f].call(a),c):g in d?d[g]:d.document.documentElement[e]:angular.isDefined(c)?d[e]=c:d[e]},b.getComputedStyle?(f=function(a){return b.getComputedStyle(a,null)},c=function(a,b){return parseFloat(b)}):(f=function(a){return a.currentStyle},c=function(a,b){var c,d,e,f,g,h,i;return c=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,f=new RegExp("^("+c+")(?!px)[a-z%]+$","i"),f.test(b)?(i=a.style,d=i.left,g=a.runtimeStyle,h=g&&g.left,g&&(g.left=i.left),i.left=b,e=i.pixelLeft,i.left=d,h&&(g.left=h),e):parseFloat(b)}),e=function(a,b){var d,e,g,i,j,k,l,m,n,o,p,q,r;return h(a)?(d=document.documentElement[{height:"clientHeight",width:"clientWidth"}[b]],{base:d,padding:0,border:0,margin:0}):(r={width:[a.offsetWidth,"Left","Right"],height:[a.offsetHeight,"Top","Bottom"]}[b],d=r[0],l=r[1],m=r[2],k=f(a),p=c(a,k["padding"+l])||0,q=c(a,k["padding"+m])||0,e=c(a,k["border"+l+"Width"])||0,g=c(a,k["border"+m+"Width"])||0,i=k["margin"+l],j=k["margin"+m],n=c(a,i)||0,o=c(a,j)||0,{base:d,padding:p+q,border:e+g,margin:n+o})},g=function(a,b,c){var d,g,h;return g=e(a,b),g.base>0?{base:g.base-g.padding-g.border,outer:g.base,outerfull:g.base+g.margin}[c]:(d=f(a),h=d[b],(0>h||null===h)&&(h=a.style[b]||0),h=parseFloat(h)||0,{base:h-g.padding-g.border,outer:h,outerfull:h+g.padding+g.border+g.margin}[c])},angular.forEach({before:function(a){var b,c,d,e,f,g,h;if(h=this,c=h[0],f=h.parent(),b=f.contents(),b[0]===c)return f.prepend(a);for(d=e=1,g=b.length-1;g>=1?g>=e:e>=g;d=g>=1?++e:--e)if(b[d]===c)return void angular.element(b[d-1]).after(a);throw new Error("invalid DOM structure "+c.outerHTML)},height:function(a){var b;return b=this,angular.isDefined(a)?(angular.isNumber(a)&&(a+="px"),d.call(b,"height",a)):g(this[0],"height","base")},outerHeight:function(a){return g(this[0],"height",a?"outerfull":"outer")},offset:function(a){var b,c,d,e,f,g;if(f=this,arguments.length){if(void 0===a)return f;throw new Error("offset setter method is not implemented")}return b={top:0,left:0},e=f[0],(c=e&&e.ownerDocument)?(d=c.documentElement,null!=e.getBoundingClientRect&&(b=e.getBoundingClientRect()),g=c.defaultView||c.parentWindow,{top:b.top+(g.pageYOffset||d.scrollTop)-(d.clientTop||0),left:b.left+(g.pageXOffset||d.scrollLeft)-(d.clientLeft||0)}):void 0},scrollTop:function(a){return i(this,"top",a)},scrollLeft:function(a){return i(this,"left",a)}},function(b,c){return a.prototype[c]?void 0:a.prototype[c]=b})}}}]).run(["$log","$window","jqLiteExtras",function(a,b,c){return b.jQuery?void 0:c.registerFor(angular.element)}])}();
\ No newline at end of file
diff --git a/dist/ui-scroll.js b/dist/ui-scroll.js
index f3a3e62a..68f1b3f8 100644
--- a/dist/ui-scroll.js
+++ b/dist/ui-scroll.js
@@ -1,7 +1,7 @@
/*!
* angular-ui-scroll
* https://github.com/angular-ui/ui-scroll.git
- * Version: 1.3.1 -- 2015-08-05T13:39:04.079Z
+ * Version: 1.3.1 -- 2015-08-06T14:43:32.930Z
* License: MIT
*/
@@ -433,6 +433,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function() {
});
};
fetch = function(rid) {
+ var customBufferSize, q, rowTop;
if (pending[0]) {
if (buffer.length && !shouldLoadBottom()) {
return finalize(rid);
@@ -461,7 +462,16 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function() {
if (buffer.length && !shouldLoadTop()) {
return finalize(rid);
} else {
- return datasource.get(first - bufferSize, bufferSize, function(result) {
+ rowTop = buffer[0].element.offset().top;
+ q = 0;
+ while (q < buffer.length) {
+ if (rowTop !== buffer[q].element.offset().top) {
+ break;
+ }
+ q++;
+ }
+ customBufferSize = bufferSize % q !== 0 ? bufferSize + q - (bufferSize % q) : bufferSize;
+ return datasource.get(first - customBufferSize, customBufferSize, function(result) {
var i, j, ref;
if ((rid && rid !== ridActual) || $scope.$$destroyed) {
return;
diff --git a/dist/ui-scroll.min.js b/dist/ui-scroll.min.js
index 9add6578..7a56e703 100644
--- a/dist/ui-scroll.min.js
+++ b/dist/ui-scroll.min.js
@@ -1,7 +1,7 @@
/*!
* angular-ui-scroll
* https://github.com/angular-ui/ui-scroll.git
- * Version: 1.3.1 -- 2015-08-05T13:39:04.079Z
+ * Version: 1.3.1 -- 2015-08-06T14:43:32.930Z
* License: MIT
*/
-!function(){"use strict";angular.module("ui.scroll",[]).directive("uiScrollViewport",function(){return{controller:["$scope","$element",function(a,b){return this.viewport=b,this}]}}).directive("uiScroll",["$log","$injector","$rootScope","$timeout","$q","$parse",function(a,b,c,d,e,f){var g;return b.has&&b.has("$animate")&&(g=b.get("$animate")),{require:["?^uiScrollViewport"],transclude:"element",priority:1e3,terminal:!0,compile:function(h,i,j){return function(h,i,k,l){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca;if(N=a.debug||a.log,!(O=k.uiScroll.match(/^\s*(\w+)\s+in\s+([\w\.]+)\s*$/)))throw new Error("Expected uiScroll in form of '_item_ in _datasource_' but got ' + $attr.uiScroll + '");if(L=O[1],z=O[2],y=f(z)(h),K=function(){return angular.isObject(y)&&angular.isFunction(y.get)},!K()&&(y=b.get(z),!K()))throw new Error(z+" is not a valid datasource");return u=Math.max(3,+k.bufferSize||10),t=function(){return aa.outerHeight()*Math.max(.1,+k.padding||.1)},W=function(a){var b;return null!=(b=a[0].scrollHeight)?b:a[0].document.documentElement.scrollHeight},v=null,V=0,G=1,P=1,s=[],Q=[],C=!1,q=!1,T=g?2===angular.version.minor?function(a){var b;return s.splice(s.indexOf(a),1),b=e.defer(),g.leave(a.element,function(){return a.scope.$destroy(),b.resolve()}),[b.promise]}:function(a){return s.splice(s.indexOf(a),1),[g.leave(a.element).then(function(){return a.scope.$destroy()})]}:function(a){return s.splice(s.indexOf(a),1),a.element.remove(),a.scope.$destroy(),[]},H=function(a,b){return i.after.apply(b,a),[]},I=g?2===angular.version.minor?function(a,b){var c;return c=e.defer(),g.enter(a,i,b,function(){return c.resolve()}),[c.promise]}:function(a,b){return[g.enter(a,i,b)]}:H,j(h.$new(),function(a){var b,c,d,e,f;if(d=a[0].localName,"dl"===d)throw new Error("ui-scroll directive does not support <"+a[0].localName+"> as a repeating tag: "+a[0].outerHTML);return"li"!==d&&"tr"!==d&&(d="div"),f=l[0]&&l[0].viewport?l[0].viewport:angular.element(window),f.css({"overflow-y":"auto",display:"block"}),c=function(a){var b,c,d;switch(a){case"tr":d=angular.element("
"),b=d.find("div"),c=d.find("tr"),c.paddingHeight=function(){return b.height.apply(b,arguments)};break;default:c=angular.element("<"+a+">"+a+">"),c.paddingHeight=c.height}return c},e=c(d),i.before(e),b=c(d),i.after(b),h.$on("$destroy",function(){return a.remove()}),v={viewport:f,topPadding:function(){return e.paddingHeight.apply(e,arguments)},bottomPadding:function(){return b.paddingHeight.apply(b,arguments)},bottomDataPos:function(){return W(f)-b.paddingHeight()},topDataPos:function(){return e.paddingHeight()},insertElement:function(a,b){return H(a,b||e)},insertElementAnimated:function(a,b){return I(a,b||e)}}}),aa=v.viewport,ba=aa.scope()||c,Z=function(a){return m.topVisible=a.scope[L],m.topVisibleElement=a.element,m.topVisibleScope=a.scope,k.topVisible&&f(k.topVisible).assign(ba,m.topVisible),k.topVisibleElement&&f(k.topVisibleElement).assign(ba,m.topVisibleElement),k.topVisibleScope&&f(k.topVisibleScope).assign(ba,m.topVisibleScope),angular.isFunction(y.topVisible)?y.topVisible(a):void 0},M=function(a){return m.isLoading=a,k.isLoading&&f(k.isLoading).assign(h,a),angular.isFunction(y.loading)?y.loading(a):void 0},S=function(a,b){var c,d,e,f;for(c=d=e=a,f=b;f>=e?f>d:d>f;c=f>=e?++d:--d)s[c].scope.$destroy(),s[c].element.remove();return s.splice(a,b-a)},A=function(){return V++,Q=[]},R=function(){return A(),G=1,P=1,S(0,s.length),v.topPadding(0),v.bottomPadding(0),C=!1,q=!1,o(V)},r=function(){return aa.scrollTop()+aa.outerHeight()},$=function(){return aa.scrollTop()},X=function(){return!C&&v.bottomDataPos()=i?0>=f:f>=0;b=0>=i?++f:--f)if(c=s[b],e=c.element.offset().top,g=j!==e,j=e,g&&(d=c.element.outerHeight(!0)),v.bottomDataPos()-a-d>r()+t())g&&(a+=d),h++,C=!1;else{if(g)break;h++}return h>0?(v.bottomPadding(v.bottomPadding()+a),S(s.length-h,s.length),P-=h):void 0},Y=function(){return!q&&v.topDataPos()>$()-t()},x=function(){var a,b,c,d,e,f,g,h,i;for(i=0,g=0,d=0,e=s.length;e>d;d++)if(a=s[d],c=a.element.offset().top,f=h!==c,h=c,f&&(b=a.element.outerHeight(!0)),v.topDataPos()+i+b<$()-t())f&&(i+=b),g++,q=!1;else{if(f)break;g++}return g>0?(v.topPadding(v.topPadding()+i),S(0,g),G+=g):void 0},B=function(a,b){return m.isLoading||M(!0),1===Q.push(b)?E(a):void 0},J=function(a,b){var c,d;if(c=h.$new(),c[L]=b,d={scope:c},j(c,function(a){return d.element=a}),a%1===0)return d.op="insert",s.splice(a,0,d);switch(d.op=a,a){case"append":return s.push(d);case"prepend":return s.unshift(d)}},o=function(a,b){var c,f,g;return c=[],f=[],g=[],d(function(){var d,h,i,j,k,l,m,n,p,q,r,t,u,w,x,y,z,A,C,D;for(d=v.bottomDataPos(),i=m=0,q=s.length;q>m;i=++m)switch(D=s[i],D.op){case"prepend":f.unshift(D);break;case"append":0===i?v.insertElement(D.element):v.insertElement(D.element,s[i-1].element),D.op="none";break;case"insert":c=0===i?c.concat(v.insertElementAnimated(D.element)):c.concat(v.insertElementAnimated(D.element,s[i-1].element)),D.op="none";break;case"remove":g.push(D)}for(n=0,r=g.length;r>n;n++)D=g[n],c=c.concat(T(D));if(v.bottomPadding(Math.max(0,v.bottomPadding()-(v.bottomDataPos()-d))),f.length){for(d=v.bottomDataPos(),p=0,t=f.length;t>p;p++)D=f[p],v.insertElement(D.element),D.op="none";h=v.bottomDataPos()-d,v.topPadding()>=h?v.topPadding(v.topPadding()-h):aa.scrollTop(aa.scrollTop()+h)}for(i=x=0,u=s.length;u>x;i=++x)j=s[i],j.scope.$index=G+i;if(X()?B(a,!0):Y()&&B(a,!1),b&&b(a),0===Q.length)for(C=0,y=0,w=s.length;w>y;y++){if(j=s[y],l=j.element.offset().top,z=A!==l,A=l,z&&(k=j.element.outerHeight(!0)),!(z&&v.topDataPos()+C+k<$())){z&&Z(j);break}C+=k}return c.length?e.all(c).then(function(){return o(a)}):void 0})},F=function(a){return o(a,function(){return Q.shift(),0===Q.length?M(!1):E(a)})},E=function(a){return Q[0]?s.length&&!X()?F(a):y.get(P,u,function(b){var c,d,e;if(!(a&&a!==V||h.$$destroyed)){if(b.length0)for(x(),d=0,e=b.length;e>d;d++)c=b[d],++P,J("append",c);return F(a)}}):s.length&&!Y()?F(a):y.get(G-u,u,function(b){var c,d,e;if(!(a&&a!==V||h.$$destroyed)){if(b.length0)for(s.length&&w(),c=d=e=b.length-1;0>=e?0>=d:d>=0;c=0>=e?++d:--d)--G,J("prepend",b[c]);return F(a)}})},U=function(){return c.$$phase||m.isLoading?void 0:(o(),h.$apply())},ca=function(a){var b,c;return b=aa[0].scrollTop,c=aa[0].scrollHeight-aa[0].clientHeight,0===b&&!q||b===c&&!C?a.preventDefault():void 0},aa.bind("resize",U),aa.bind("scroll",U),aa.bind("mousewheel",ca),h.$watch(y.revision,R),h.$on("$destroy",function(){var a,b,c;for(b=0,c=s.length;c>b;b++)a=s[b],a.scope.$destroy(),a.element.remove();return aa.unbind("resize",U),aa.unbind("scroll",U),aa.unbind("mousewheel",ca)}),m={},m.isLoading=!1,m.reload=R,p=function(a,b){var c,d,e,f,g,h,i;if(angular.isArray(b)){for(h=s.indexOf(a)+1,i=b.reverse(),c=d=0,f=i.length;f>d;c=++d)g=i[c],g===a.scope[L]?(e=!0,h--):J(h,g);if(!e)return a.op="remove"}},m.applyUpdates=function(a,b){var c,d,e,f,g,h;if(A(),angular.isFunction(a))for(c=s.slice(0),d=e=0,f=c.length;f>e;d=++e)h=c[d],p(h,a(h.scope[L],h.scope,h.element));else{if(a%1!==0)throw new Error("applyUpdates - "+a+" is not a valid index");0<=(g=a-G)&&gc;c++)b=a[c],++P,J("append",b);return o(V)},m.prepend=function(a){var b,c,d,e;for(A(),e=a.reverse(),c=0,d=e.length;d>c;c++)b=e[c],--G,J("prepend",b);return o(V)},k.adapter&&(n=f(k.adapter)(h),n||(f(k.adapter).assign(h,{}),n=f(k.adapter)(h)),angular.extend(n,m),m=n),_=function(a){throw new Error(a+" event is no longer supported - use applyUpdates instead")},D=y.scope?y.scope.$new():h.$new(),D.$on("insert.item",function(){return _("insert")}),D.$on("update.items",function(){return _("update")}),D.$on("delete.items",function(){return _("delete")})}}}}])}();
\ No newline at end of file
+!function(){"use strict";angular.module("ui.scroll",[]).directive("uiScrollViewport",function(){return{controller:["$scope","$element",function(a,b){return this.viewport=b,this}]}}).directive("uiScroll",["$log","$injector","$rootScope","$timeout","$q","$parse",function(a,b,c,d,e,f){var g;return b.has&&b.has("$animate")&&(g=b.get("$animate")),{require:["?^uiScrollViewport"],transclude:"element",priority:1e3,terminal:!0,compile:function(h,i,j){return function(h,i,k,l){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca;if(N=a.debug||a.log,!(O=k.uiScroll.match(/^\s*(\w+)\s+in\s+([\w\.]+)\s*$/)))throw new Error("Expected uiScroll in form of '_item_ in _datasource_' but got ' + $attr.uiScroll + '");if(L=O[1],z=O[2],y=f(z)(h),K=function(){return angular.isObject(y)&&angular.isFunction(y.get)},!K()&&(y=b.get(z),!K()))throw new Error(z+" is not a valid datasource");return u=Math.max(3,+k.bufferSize||10),t=function(){return aa.outerHeight()*Math.max(.1,+k.padding||.1)},W=function(a){var b;return null!=(b=a[0].scrollHeight)?b:a[0].document.documentElement.scrollHeight},v=null,V=0,G=1,P=1,s=[],Q=[],C=!1,q=!1,T=g?2===angular.version.minor?function(a){var b;return s.splice(s.indexOf(a),1),b=e.defer(),g.leave(a.element,function(){return a.scope.$destroy(),b.resolve()}),[b.promise]}:function(a){return s.splice(s.indexOf(a),1),[g.leave(a.element).then(function(){return a.scope.$destroy()})]}:function(a){return s.splice(s.indexOf(a),1),a.element.remove(),a.scope.$destroy(),[]},H=function(a,b){return i.after.apply(b,a),[]},I=g?2===angular.version.minor?function(a,b){var c;return c=e.defer(),g.enter(a,i,b,function(){return c.resolve()}),[c.promise]}:function(a,b){return[g.enter(a,i,b)]}:H,j(h.$new(),function(a){var b,c,d,e,f;if(d=a[0].localName,"dl"===d)throw new Error("ui-scroll directive does not support <"+a[0].localName+"> as a repeating tag: "+a[0].outerHTML);return"li"!==d&&"tr"!==d&&(d="div"),f=l[0]&&l[0].viewport?l[0].viewport:angular.element(window),f.css({"overflow-y":"auto",display:"block"}),c=function(a){var b,c,d;switch(a){case"tr":d=angular.element(""),b=d.find("div"),c=d.find("tr"),c.paddingHeight=function(){return b.height.apply(b,arguments)};break;default:c=angular.element("<"+a+">"+a+">"),c.paddingHeight=c.height}return c},e=c(d),i.before(e),b=c(d),i.after(b),h.$on("$destroy",function(){return a.remove()}),v={viewport:f,topPadding:function(){return e.paddingHeight.apply(e,arguments)},bottomPadding:function(){return b.paddingHeight.apply(b,arguments)},bottomDataPos:function(){return W(f)-b.paddingHeight()},topDataPos:function(){return e.paddingHeight()},insertElement:function(a,b){return H(a,b||e)},insertElementAnimated:function(a,b){return I(a,b||e)}}}),aa=v.viewport,ba=aa.scope()||c,Z=function(a){return m.topVisible=a.scope[L],m.topVisibleElement=a.element,m.topVisibleScope=a.scope,k.topVisible&&f(k.topVisible).assign(ba,m.topVisible),k.topVisibleElement&&f(k.topVisibleElement).assign(ba,m.topVisibleElement),k.topVisibleScope&&f(k.topVisibleScope).assign(ba,m.topVisibleScope),angular.isFunction(y.topVisible)?y.topVisible(a):void 0},M=function(a){return m.isLoading=a,k.isLoading&&f(k.isLoading).assign(h,a),angular.isFunction(y.loading)?y.loading(a):void 0},S=function(a,b){var c,d,e,f;for(c=d=e=a,f=b;f>=e?f>d:d>f;c=f>=e?++d:--d)s[c].scope.$destroy(),s[c].element.remove();return s.splice(a,b-a)},A=function(){return V++,Q=[]},R=function(){return A(),G=1,P=1,S(0,s.length),v.topPadding(0),v.bottomPadding(0),C=!1,q=!1,o(V)},r=function(){return aa.scrollTop()+aa.outerHeight()},$=function(){return aa.scrollTop()},X=function(){return!C&&v.bottomDataPos()=i?0>=f:f>=0;b=0>=i?++f:--f)if(c=s[b],e=c.element.offset().top,g=j!==e,j=e,g&&(d=c.element.outerHeight(!0)),v.bottomDataPos()-a-d>r()+t())g&&(a+=d),h++,C=!1;else{if(g)break;h++}return h>0?(v.bottomPadding(v.bottomPadding()+a),S(s.length-h,s.length),P-=h):void 0},Y=function(){return!q&&v.topDataPos()>$()-t()},x=function(){var a,b,c,d,e,f,g,h,i;for(i=0,g=0,d=0,e=s.length;e>d;d++)if(a=s[d],c=a.element.offset().top,f=h!==c,h=c,f&&(b=a.element.outerHeight(!0)),v.topDataPos()+i+b<$()-t())f&&(i+=b),g++,q=!1;else{if(f)break;g++}return g>0?(v.topPadding(v.topPadding()+i),S(0,g),G+=g):void 0},B=function(a,b){return m.isLoading||M(!0),1===Q.push(b)?E(a):void 0},J=function(a,b){var c,d;if(c=h.$new(),c[L]=b,d={scope:c},j(c,function(a){return d.element=a}),a%1===0)return d.op="insert",s.splice(a,0,d);switch(d.op=a,a){case"append":return s.push(d);case"prepend":return s.unshift(d)}},o=function(a,b){var c,f,g;return c=[],f=[],g=[],d(function(){var d,h,i,j,k,l,m,n,p,q,r,t,u,w,x,y,z,A,C,D;for(d=v.bottomDataPos(),i=m=0,q=s.length;q>m;i=++m)switch(D=s[i],D.op){case"prepend":f.unshift(D);break;case"append":0===i?v.insertElement(D.element):v.insertElement(D.element,s[i-1].element),D.op="none";break;case"insert":c=0===i?c.concat(v.insertElementAnimated(D.element)):c.concat(v.insertElementAnimated(D.element,s[i-1].element)),D.op="none";break;case"remove":g.push(D)}for(n=0,r=g.length;r>n;n++)D=g[n],c=c.concat(T(D));if(v.bottomPadding(Math.max(0,v.bottomPadding()-(v.bottomDataPos()-d))),f.length){for(d=v.bottomDataPos(),p=0,t=f.length;t>p;p++)D=f[p],v.insertElement(D.element),D.op="none";h=v.bottomDataPos()-d,v.topPadding()>=h?v.topPadding(v.topPadding()-h):aa.scrollTop(aa.scrollTop()+h)}for(i=x=0,u=s.length;u>x;i=++x)j=s[i],j.scope.$index=G+i;if(X()?B(a,!0):Y()&&B(a,!1),b&&b(a),0===Q.length)for(C=0,y=0,w=s.length;w>y;y++){if(j=s[y],l=j.element.offset().top,z=A!==l,A=l,z&&(k=j.element.outerHeight(!0)),!(z&&v.topDataPos()+C+k<$())){z&&Z(j);break}C+=k}return c.length?e.all(c).then(function(){return o(a)}):void 0})},F=function(a){return o(a,function(){return Q.shift(),0===Q.length?M(!1):E(a)})},E=function(a){var b,c,d;if(Q[0])return s.length&&!X()?F(a):y.get(P,u,function(b){var c,d,e;if(!(a&&a!==V||h.$$destroyed)){if(b.length0)for(x(),d=0,e=b.length;e>d;d++)c=b[d],++P,J("append",c);return F(a)}});if(s.length&&!Y())return F(a);for(d=s[0].element.offset().top,c=0;c0)for(s.length&&w(),c=d=e=b.length-1;0>=e?0>=d:d>=0;c=0>=e?++d:--d)--G,J("prepend",b[c]);return F(a)}})},U=function(){return c.$$phase||m.isLoading?void 0:(o(),h.$apply())},ca=function(a){var b,c;return b=aa[0].scrollTop,c=aa[0].scrollHeight-aa[0].clientHeight,0===b&&!q||b===c&&!C?a.preventDefault():void 0},aa.bind("resize",U),aa.bind("scroll",U),aa.bind("mousewheel",ca),h.$watch(y.revision,R),h.$on("$destroy",function(){var a,b,c;for(b=0,c=s.length;c>b;b++)a=s[b],a.scope.$destroy(),a.element.remove();return aa.unbind("resize",U),aa.unbind("scroll",U),aa.unbind("mousewheel",ca)}),m={},m.isLoading=!1,m.reload=R,p=function(a,b){var c,d,e,f,g,h,i;if(angular.isArray(b)){for(h=s.indexOf(a)+1,i=b.reverse(),c=d=0,f=i.length;f>d;c=++d)g=i[c],g===a.scope[L]?(e=!0,h--):J(h,g);if(!e)return a.op="remove"}},m.applyUpdates=function(a,b){var c,d,e,f,g,h;if(A(),angular.isFunction(a))for(c=s.slice(0),d=e=0,f=c.length;f>e;d=++e)h=c[d],p(h,a(h.scope[L],h.scope,h.element));else{if(a%1!==0)throw new Error("applyUpdates - "+a+" is not a valid index");0<=(g=a-G)&&gc;c++)b=a[c],++P,J("append",b);return o(V)},m.prepend=function(a){var b,c,d,e;for(A(),e=a.reverse(),c=0,d=e.length;d>c;c++)b=e[c],--G,J("prepend",b);return o(V)},k.adapter&&(n=f(k.adapter)(h),n||(f(k.adapter).assign(h,{}),n=f(k.adapter)(h)),angular.extend(n,m),m=n),_=function(a){throw new Error(a+" event is no longer supported - use applyUpdates instead")},D=y.scope?y.scope.$new():h.$new(),D.$on("insert.item",function(){return _("insert")}),D.$on("update.items",function(){return _("update")}),D.$on("delete.items",function(){return _("delete")})}}}}])}();
\ No newline at end of file
diff --git a/src/ui-scroll.coffee b/src/ui-scroll.coffee
index 09dc9a25..bda00b7b 100644
--- a/src/ui-scroll.coffee
+++ b/src/ui-scroll.coffee
@@ -389,8 +389,18 @@ angular.module('ui.scroll', [])
if buffer.length && !shouldLoadTop()
finalize rid
else
+ rowTop = buffer[0].element.offset().top
+ q = 0
+ while q < buffer.length
+ if rowTop != buffer[q].element.offset().top
+ break
+ q++
+
+ customBufferSize = if bufferSize % q != 0 then bufferSize + q - (bufferSize % q) else bufferSize
+
#log "prepending... requested #{size} records starting from #{start}"
- datasource.get first-bufferSize, bufferSize,
+
+ datasource.get first-customBufferSize, customBufferSize,
(result) ->
return if (rid and rid isnt ridActual) or $scope.$$destroyed
if result.length < bufferSize