Some cleanup

This commit is contained in:
Catalin Constantin Mititiuc 2024-07-29 20:47:14 -07:00
parent f1f8ced0b8
commit deb3f2db61

View File

@ -1551,39 +1551,23 @@
const out = document.querySelector('#out'); const out = document.querySelector('#out');
const store = new Map(); const store = new Map();
//svg.addEventListener('pointerout', e => {
// if (e.target !== svg)
// console.log('SVG pointerout', 'from', e.target?.parentElement, 'to', e.relatedTarget?.parentElement);
//});
//const tiles = svg.querySelector('
svg.addEventListener('pointerover', e => { svg.addEventListener('pointerover', e => {
console.log('SVG pointerover', e.target.closest('g')); console.log('SVG pointerover', e.target.closest('g'));
const g = e.target.closest('g:not(#out)'); const g = e.target.closest('g:not(#out)');
const circle = g && g.querySelector('circle');
if (g && g.querySelector('circle')) { if (circle) {
out.setAttributeNS(null, 'transform', g.getAttributeNS(null, 'transform')); out.setAttributeNS(null, 'transform', g.getAttributeNS(null, 'transform'));
const circle = g.querySelector('circle');
store.set(circle, g); store.set(circle, g);
out.append(circle); out.append(circle);
} }
//if (e.target.tagName === 'use') {
// out.setAttributeNS(null, 'transform', e.target.getAttribute
//}
}); });
svg.addEventListener('pointerout', e => { svg.addEventListener('pointerout', e => {
console.log('pointer out target', e.target); console.log('pointer out target', e.target);
const g = e.target.closest('g'); const g = e.target.closest('g');
if (g) { if (g) {
if (g.id === 'out') {
console.log('SVG pointerout OUT', store.get(e.target));
[...out.children].forEach(child => {
store.get(child).append(child);
store.delete(child);
});
} else {
console.log('SVG pointerout', e.target.closest('g')); console.log('SVG pointerout', e.target.closest('g'));
[...out.children].forEach(child => { [...out.children].forEach(child => {
console.log('child', child, 'belongs to', store.get(child)); console.log('child', child, 'belongs to', store.get(child));
@ -1594,30 +1578,18 @@
store.delete(child); store.delete(child);
} }
}); });
}
} else { } else {
if (g && g.id === 'out')
console.log('SVG pointerout OUT', store.get(e.target));
else
console.log('SVG pointerout', e.target); console.log('SVG pointerout', e.target);
[...out.children].forEach(child => { [...out.children].forEach(child => {
store.get(child).append(child); store.get(child).append(child);
store.delete(child); store.delete(child);
}); });
} }
}); });
//document.querySelectorAll('g:not(#out)').forEach(g => {
// const circle = g.querySelector('circle');
//
// g.addEventListener('pointerover', e => {
// console.log('pointer over', g.id);
// svg.append(g);
// circle.setAttributeNS(null, 'transform', 'scale(3)');
// });
//
// g.addEventListener('pointerleave', e => {
// console.log('pointer leave', g.id);
// circle.removeAttributeNS(null, 'transform');
// });
//})
//]]> //]]>
</script> </script>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 27 KiB