Cleaned up code and fixed a few bugs with the pagination code that was messing up with the order of elements when rendering.
This commit is contained in:
@ -1414,7 +1414,7 @@ class IgniteTemplate {
|
|||||||
* Constructs this template and adds it to the DOM if this template
|
* Constructs this template and adds it to the DOM if this template
|
||||||
* has not already been constructed.
|
* has not already been constructed.
|
||||||
* @param {HTMLElement} parent Parent element that will contain the constructed element.
|
* @param {HTMLElement} parent Parent element that will contain the constructed element.
|
||||||
* @param {HTMLElement} sibling Optional sibling element that can be used to add the element adjacantly.
|
* @param {HTMLElement} sibling Optional sibling element that when set inserts this element after it.
|
||||||
*/
|
*/
|
||||||
construct(parent, sibling) {
|
construct(parent, sibling) {
|
||||||
//Don't construct if we have no parent, no sibling and no element.
|
//Don't construct if we have no parent, no sibling and no element.
|
||||||
@ -3337,7 +3337,7 @@ class pagination extends IgniteTemplate {
|
|||||||
|
|
||||||
//Adjust the current page if it's now incorrect.
|
//Adjust the current page if it's now incorrect.
|
||||||
if (this.currentPage >= pages) {
|
if (this.currentPage >= pages) {
|
||||||
this.currentPage = pages - 1;
|
this.currentPage = Math.max(0, pages - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show the elements in the current page
|
//Show the elements in the current page
|
||||||
@ -3401,10 +3401,12 @@ class pagination extends IgniteTemplate {
|
|||||||
|
|
||||||
//Construct all the items in our list and use the container
|
//Construct all the items in our list and use the container
|
||||||
if (this.list) {
|
if (this.list) {
|
||||||
|
var last = this.element;
|
||||||
|
|
||||||
for (var i = 0; i < this.list.length; i++) {
|
for (var i = 0; i < this.list.length; i++) {
|
||||||
var template = this.forEach(this.list[i]);
|
var template = this.forEach(this.list[i]);
|
||||||
|
|
||||||
template.construct(parent, this.element);
|
template.construct(parent, last);
|
||||||
|
|
||||||
var page = parseInt(i / this.pageSize);
|
var page = parseInt(i / this.pageSize);
|
||||||
if (page != this.currentPage) {
|
if (page != this.currentPage) {
|
||||||
@ -3416,6 +3418,7 @@ class pagination extends IgniteTemplate {
|
|||||||
this.pages[page].push(template.element);
|
this.pages[page].push(template.element);
|
||||||
this.children.push(template);
|
this.children.push(template);
|
||||||
this.elements.push(template.element);
|
this.elements.push(template.element);
|
||||||
|
last = template.element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3464,16 +3467,20 @@ class pagination extends IgniteTemplate {
|
|||||||
IgniteRendering.enter();
|
IgniteRendering.enter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var last = this.element;
|
||||||
|
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
var template = this.forEach(item);
|
var template = this.forEach(item);
|
||||||
|
|
||||||
template.construct(this.element.parentElement, this.element);
|
template.construct(this.element.parentElement, last);
|
||||||
|
|
||||||
template.element.style.setProperty("display", "none", "important");
|
template.element.style.setProperty("display", "none", "important");
|
||||||
|
|
||||||
this.children.push(template);
|
this.children.push(template);
|
||||||
|
|
||||||
this.elements.push(template.element);
|
this.elements.push(template.element);
|
||||||
|
|
||||||
|
last = template.element;
|
||||||
});
|
});
|
||||||
|
|
||||||
//Recalculate the pagination.
|
//Recalculate the pagination.
|
||||||
@ -3563,7 +3570,7 @@ class pagination extends IgniteTemplate {
|
|||||||
if (this.elements.length > 0) {
|
if (this.elements.length > 0) {
|
||||||
template.construct(this.element.parentElement, this.elements[start]);
|
template.construct(this.element.parentElement, this.elements[start]);
|
||||||
} else {
|
} else {
|
||||||
template.construct(this.element.parentElement, null);
|
template.construct(this.element.parentElement, this.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
template.element.style.setProperty("display", "none", "important");
|
template.element.style.setProperty("display", "none", "important");
|
||||||
|
Reference in New Issue
Block a user