Skip to content

Commit

Permalink
Fix indices when traversing rows
Browse files Browse the repository at this point in the history
widmoser committed Jun 3, 2016
1 parent 4ef5f5a commit 91eb6c7
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions dist/tileview.js
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@
var cachedRowCount;
var virtualRows = [];
function handleTileSizeChange() {
forEachElement(function (el, i) {
forEachElement(function (el) {
el.css('width', scope.options.tileSize.width + 'px');
el.css('height', scope.options.tileSize.height + 'px');
});
@@ -129,16 +129,16 @@
forEachRow(removeRow);
}
function forEachElement(fn) {
forEachRow(function (row) {
forEachRow(function (row, rowIndex) {
for (var i = 0; i < row.children().length; ++i) {
fn(row.children().eq(i), i);
fn(row.children().eq(i), rowIndex * itemsPerRow + i);
}
});
}
function forEachRow(fn) {
var numOfElements = visibleRowCount();
for (var i = 0; i < numOfElements; ++i) {
fn(itemContainer.children().eq(i), i);
var numOfRows = visibleRowCount();
for (var i = 0; i < numOfRows; ++i) {
fn(itemContainer.children().eq(i), startRow + i);
}
}
function visibleRowCount() {
@@ -243,7 +243,7 @@
var startIndex = startRow * itemsPerRow;
forEachRow(function (el, i) {
virtualRows.push(el);
updateRow(el, startRow + i, false);
updateRow(el, i, false);
});
renderedStartRow = startRow;
renderedEndRow = endRow;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-tileview",
"version": "0.6.0",
"version": "0.6.1",
"description": "A tileview for angular",
"main": "gulpfile.js",
"scripts": {
14 changes: 7 additions & 7 deletions src/tileview.ts
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ declare const angular: any;
let virtualRows = [];

function handleTileSizeChange() {
forEachElement((el, i) => {
forEachElement(el => {
el.css('width', scope.options.tileSize.width + 'px');
el.css('height', scope.options.tileSize.height + 'px');
});
@@ -149,17 +149,17 @@ declare const angular: any;
}

function forEachElement(fn) {
forEachRow(row => {
forEachRow((row, rowIndex) => {
for (let i = 0; i < row.children().length; ++i) {
fn(row.children().eq(i), i);
fn(row.children().eq(i), rowIndex*itemsPerRow + i);
}
});
}

function forEachRow(fn) {
const numOfElements = visibleRowCount();
for (let i = 0; i < numOfElements; ++i) {
fn(itemContainer.children().eq(i), i);
const numOfRows = visibleRowCount();
for (let i = 0; i < numOfRows; ++i) {
fn(itemContainer.children().eq(i), startRow + i);
}
}

@@ -280,7 +280,7 @@ declare const angular: any;
const startIndex = startRow * itemsPerRow;
forEachRow((el, i) => {
virtualRows.push(el);
updateRow(el, startRow + i, false);
updateRow(el, i, false);
});
renderedStartRow = startRow;
renderedEndRow = endRow;

0 comments on commit 91eb6c7

Please sign in to comment.