-
Notifications
You must be signed in to change notification settings - Fork 94
Opacity not updating on change #38
Copy link
Copy link
Open
Description
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);
}Hope this helps !
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
