Files
ionic-framework/test/js/views/listView.unit.js
Andy Joslin 7f4b28d9da feat(list): reordering scrolls page, reordering performance better
Fixes #521. Reordering now uses webkitTransform instead of
element.style.left.  Additionally, as you drag the drag-element to the
top or bottom of the scroll-area, it will scroll it up or down as
allowed.

Refactors necessary: Common code from `<content>` and `<scroll>` moved
into js/ext/angular/controllers/ionicScrollController.  Then `<content>`
and `<scroll>` expose the controller, and `<list>` can require it.

`<list>` then uses the controller (if exists) to pass the scrollView and
scrollEl to ReorderDrag, and ReorderDrag uses that to scroll.

Additionally, js/ext/angular/test/controller/ionicScrollController tests
much functionality that was untested before.
2014-02-06 15:04:23 -05:00

77 lines
2.0 KiB
JavaScript

describe('List View', function() {
var h, listEl;
beforeEach(function() {
h = document.createElement('div');
h.id = 'content';
h.className = 'scroll';
var l = document.createElement('ul');
l.className = 'list scroll';
h.appendChild(l);
listEl = l;
for(var i = 0; i < 1000; i++) {
var li = document.createElement('li');
li.style.height = '50px';
l.appendChild(li);
}
document.body.style.height='1000px';
document.body.appendChild(h);
});
it('Should init', function() {
var list = new ionic.views.ListView({
el: h,
});
});
it('Should init item height from CSS', function() {
var list = new ionic.views.ListView({
el: h,
listEl: listEl,
isVirtual: true,
});
expect(list.itemHeight).toEqual(50);
});
/*
it('Should support virtual scrolling', function() {
var list = new ionic.views.ListView({
el: h,
listEl: listEl,
isVirtual: true,
itemHeight: 50,
virtualRemoveThreshold: -200,
virtualAddThreshold: 200
});
list.renderViewport = function(high, low, start, end) {
};
var spy = spyOn(list, 'renderViewport');
var height = h.scrollHeight;
var itemHeight = list.itemHeight;
var totalItems = height / itemHeight;
var viewportHeight = list.el.parentNode.offsetHeight;
var itemsPerViewport = (viewportHeight + -list.virtualRemoveThreshold + list.virtualAddThreshold) / itemHeight;
// set up scroll top
var scrollTop = 1000;
var start = (scrollTop + list.virtualRemoveThreshold) / itemHeight;
var end = (scrollTop + viewportHeight + list.virtualAddThreshold) / itemHeight;
list.scrollTo(0, scrollTop);
// Given a scrollTop of 1000px, an item height of 50px, and the given += 200px
// render window, renderViewport should be called with the following
// computed values:
expect(list.renderViewport).toHaveBeenCalledWith(scrollTop + list.virtualRemoveThreshold,
scrollTop + viewportHeight + list.virtualAddThreshold, start, end);
});
*/
});