Skip to content

Commit

Permalink
fixed removing replaced objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Joseph authored and Anselm Joseph committed Jul 18, 2019
1 parent 3bd8a73 commit c5524b0
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions dist/tea-plates.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,6 @@ class TeaPlates {
});
}

removeAllObjects(completion = () => {}) {
let completionPromise = [];
this.insertedElements.slice().reverse()
.forEach((element, index) => {
let promise = new Promise((resolve, _reject) => {
setTimeout(() => {
element.classList.add("animate-out");
setTimeout(() => {
document.getElementById(this.wrapperId).removeChild(element);
resolve();
}, this.animationTime, element, this, index);
}, this.delta * index, element, this, index);
});
completionPromise.push(promise);
});
Promise.all(completionPromise)
.then(() => {
this.insertedElements = [];
completion();
});
}

registerEventListeners(eventType, eventHandler, options = false) {
let listener = {
'type': eventType,
Expand Down Expand Up @@ -173,6 +151,7 @@ class TeaPlates {
this.insertedElements.forEach((ele, i) => {
if (ele.getAttribute('uid') == uid) {
element = ele;
index = i;
}
});
if (element == undefined) return;
Expand Down Expand Up @@ -228,6 +207,28 @@ class TeaPlates {
return this.jsonData[`uid-${uid}`];
}

removeAllObjects(completion = () => {}) {
let completionPromise = [];
this.insertedElements.slice().reverse()
.forEach((element, index) => {
let promise = new Promise((resolve, _reject) => {
setTimeout(() => {
element.classList.add("animate-out");
setTimeout(() => {
document.getElementById(this.wrapperId).removeChild(element);
resolve();
}, this.animationTime, element, this, index);
}, this.delta * index, element, this, index);
});
completionPromise.push(promise);
});
Promise.all(completionPromise)
.then(() => {
this.insertedElements = [];
completion();
});
}

pTP_CreateElementFromString(htmlString, uid = -1) {
var div = document.createElement('div');
div.innerHTML = htmlString;
Expand Down

0 comments on commit c5524b0

Please sign in to comment.