Skip to content

Commit

Permalink
fix(Layout): add prepending code
Browse files Browse the repository at this point in the history
  • Loading branch information
itoolsg committed Oct 23, 2017
1 parent f1e93f8 commit a82f033
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/layouts/GridLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class GridLayout {
item.column = index;
endOutline[index] = isAppend ? endPos1 : pos1;
}
if (!isAppend) {
items.sort((a, b) => a.rect.top - b.rect.top);
}
// if append items, startOutline is low, endOutline is high
// if prepend items, startOutline is high, endOutline is low
return {
Expand Down
6 changes: 3 additions & 3 deletions test/manual/layouts/GridLayout.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
return 200 / images[i][0] * images[i][1];
}

append([], 9);
append(undefined, 12);
append(undefined, 7);
prepend([1000], 9);
// append(undefined, 12);
// append(undefined, 7);
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions test/manual/layouts/js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function append(line, num = 22) {


result.items.forEach((item, i) => {
item.el = items[i].el;
item.groupKey = group;
item.el.dataset.group = group;
});
Expand All @@ -88,7 +87,6 @@ function prepend(line, num = 22) {
const items = getItems(num);
const result = a.prepend(items, getTopline(line));
result.items.forEach((item, i) => {
item.el = items[i].el;
item.groupKey = group;
item.el.dataset.group = group;
});
Expand Down

0 comments on commit a82f033

Please sign in to comment.