1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-22 05:33:06 +02:00

fix hello world, clean up reconciliation

This commit is contained in:
Morris Brodersen
2020-10-21 12:23:39 +02:00
parent 23ad2d043d
commit bf35608693
4 changed files with 36 additions and 18 deletions

View File

@@ -62,7 +62,7 @@ VT.TodoFrameCustom = function (el) {
el.addEventListener('draggableOver', function (e) {
if (!e.detail.data.list) return;
updateTranslation();
updatePositions();
});
el.todoFrameCustom = {
@@ -75,11 +75,14 @@ VT.TodoFrameCustom = function (el) {
var lists = getLists();
var container = el.querySelector('.container');
var obsolete = new Set(container.children);
var childrenByKey = new Map();
obsolete.forEach(function (child) {
childrenByKey.set(child.getAttribute('data-key'), child);
});
var children = lists.map(function (list) {
var child = container.querySelector(
'.todo-custom-list[data-key="' + list.id + '"]'
);
var child = childrenByKey.get(list.id);
if (child) {
obsolete.delete(child);
@@ -105,11 +108,11 @@ VT.TodoFrameCustom = function (el) {
}
});
updateTranslation();
updatePositions();
updateHeight();
}
function updateTranslation() {
function updatePositions() {
el.querySelectorAll('.container > *').forEach(function (child, index) {
child.style.transform = 'translateX(' + (index - state.at) * 100 + '%)';
});