Working on virtual list scroll stuff

This commit is contained in:
Max Lynch
2013-10-28 12:37:37 -05:00
parent a3edee2ff9
commit e619e9be72
3 changed files with 11 additions and 10 deletions

10
dist/js/ionic.js vendored
View File

@ -3363,18 +3363,18 @@ window.ionic = {
console.log('Scrolling', Date.now()); console.log('Scrolling', Date.now());
if(this.isVirtual) { if(this.isVirtual) {
var itemHeight = this.itemHeight; var itemHeight = this.itemHeight;
var totalItems = this.el.children.length; var totalItems = this.listEl.children.length;
var scrollHeight = e.target.scrollHeight var scrollHeight = e.target.scrollHeight
var scrollTop = e.scrollTop; var scrollTop = e.scrollTop;
var height = this.el.parentNode.offsetHeight; var height = this.el.parentNode.offsetHeight;
console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height);
var itemsPerPage = Math.floor(scrollHeight / itemHeight); var itemsPerPage = Math.floor(height / itemHeight);
var first = parseInt(scrollTop / itemHeight) - totalItems; var first = parseInt(scrollTop / itemHeight);
console.log('FITS', itemsPerPage, 'per page, starting at', first); console.log('FITS', itemsPerPage, 'per page, starting at', first);
var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); var nodes = Array.prototype.slice.call(this.listEl.children, first, first + itemsPerPage);
console.log('Showing these nodes:', nodes); console.log('Showing these', nodes.length, 'nodes:', nodes);
} }
}, },

View File

@ -396,18 +396,18 @@
console.log('Scrolling', Date.now()); console.log('Scrolling', Date.now());
if(this.isVirtual) { if(this.isVirtual) {
var itemHeight = this.itemHeight; var itemHeight = this.itemHeight;
var totalItems = this.el.children.length; var totalItems = this.listEl.children.length;
var scrollHeight = e.target.scrollHeight var scrollHeight = e.target.scrollHeight
var scrollTop = e.scrollTop; var scrollTop = e.scrollTop;
var height = this.el.parentNode.offsetHeight; var height = this.el.parentNode.offsetHeight;
console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height); console.log('LIST VIEW SCROLLED', e, itemHeight, scrollHeight, height);
var itemsPerPage = Math.floor(scrollHeight / itemHeight); var itemsPerPage = Math.floor(height / itemHeight);
var first = parseInt(scrollTop / itemHeight) - totalItems; var first = parseInt(scrollTop / itemHeight);
console.log('FITS', itemsPerPage, 'per page, starting at', first); console.log('FITS', itemsPerPage, 'per page, starting at', first);
var nodes = Array.prototype.slice.call(this.el.children, first, itemsPerPage); var nodes = Array.prototype.slice.call(this.listEl.children, first, first + itemsPerPage);
console.log('Showing these nodes:', nodes); console.log('Showing these', nodes.length, 'nodes:', nodes);
} }
}, },

View File

@ -1279,6 +1279,7 @@
var list = document.getElementById('content'); var list = document.getElementById('content');
var lv = new ionic.views.ListView({ var lv = new ionic.views.ListView({
el: list, el: list,
listEl: list.children[0],
isVirtual: true, isVirtual: true,
itemHeight: 50 itemHeight: 50
}); });