I'm trying to implement this TagCloud as a ImageCloud but I encountered a problem with the opacity / Zindex :
I resolved it by adding an observer to every .tagcloud--item. I've not managed changed object class name but here is the code:
// Options for the observer (which mutations to observe)
const config = {attributes: true, attributeFilter: ['style']};
// Callback function to execute when mutations are observed
const changeOpacity = function (mutationsList, _) {
for (const mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
mutation.target.style.zIndex = 100 * (mutation.target.style.opacity);
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(changeOpacity);
const tags = document.querySelectorAll(.tagcloud--item);
for (const tag of tags) {
// Start observing the target node for configured mutations
observer.observe(tag, config);
}
I'm trying to implement this TagCloud as a ImageCloud but I encountered a problem with the opacity / Zindex :![image](https://github.com/cong-min/TagCloud/assets/68811269/42c25f40-8605-43e3-ab08-680159e9ef6b)
I resolved it by adding an observer to every
.tagcloud--item
. I've not managed changed object class name but here is the code:Here is the final result 👍![image](https://github.com/cong-min/TagCloud/assets/68811269/deea380c-06c1-47f0-9089-613c22743ca5)
Hope this helps !