diff --git a/dist/js/ionic.js b/dist/js/ionic.js index f329226704..5c6484bec6 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -3363,18 +3363,18 @@ window.ionic = { console.log('Scrolling', Date.now()); if(this.isVirtual) { var itemHeight = this.itemHeight; - var totalItems = this.el.children.length; + var totalItems = this.listEl.children.length; var scrollHeight = e.target.scrollHeight var scrollTop = e.scrollTop; var height = this.el.parentNode.offsetHeight; console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); - var itemsPerPage = Math.floor(scrollHeight / itemHeight); - var first = parseInt(scrollTop / itemHeight) - totalItems; + var itemsPerPage = Math.floor(height / itemHeight); + var first = parseInt(scrollTop / itemHeight); console.log('FITS', itemsPerPage, 'per page, starting at', first); - var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); - console.log('Showing these nodes:', nodes); + var nodes = Array.prototype.slice.call(this.listEl.children, first, first + itemsPerPage); + console.log('Showing these', nodes.length, 'nodes:', nodes); } }, diff --git a/js/views/listViewScroll.js b/js/views/listViewScroll.js index cda9670cf3..ca5f467913 100644 --- a/js/views/listViewScroll.js +++ b/js/views/listViewScroll.js @@ -396,18 +396,18 @@ console.log('Scrolling', Date.now()); if(this.isVirtual) { var itemHeight = this.itemHeight; - var totalItems = this.el.children.length; + var totalItems = this.listEl.children.length; var scrollHeight = e.target.scrollHeight var scrollTop = e.scrollTop; var height = this.el.parentNode.offsetHeight; console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); - var itemsPerPage = Math.floor(scrollHeight / itemHeight); - var first = parseInt(scrollTop / itemHeight) - totalItems; + var itemsPerPage = Math.floor(height / itemHeight); + var first = parseInt(scrollTop / itemHeight); console.log('FITS', itemsPerPage, 'per page, starting at', first); - var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); - console.log('Showing these nodes:', nodes); + var nodes = Array.prototype.slice.call(this.listEl.children, first, first + itemsPerPage); + console.log('Showing these', nodes.length, 'nodes:', nodes); } }, diff --git a/test/biglists.html b/test/biglists.html index 4bd24a14fe..692686be48 100644 --- a/test/biglists.html +++ b/test/biglists.html @@ -1279,6 +1279,7 @@ var list = document.getElementById('content'); var lv = new ionic.views.ListView({ el: list, + listEl: list.children[0], isVirtual: true, itemHeight: 50 });