I'm trying to make a layout with some cards, which, when clicked, open to reveal more information, like you can see in this image. I managed to get most of the stuff working, but I can't get the little banner on the left to morph into it's open state. From what I've seen, the best way to go about this is using anime.js, but it doesn't work, for some reason. Here's the code:
let cardToggle = document.querySelectorAll('.card-toggle');
for (i = 0; i < cardToggle.length; i++) {
cardToggle[i].addEventListener("click", function() {
//Get the required elements
let cardContent = this.nextElementSibling;
let cardBackground = this.parentElement;
let metaWrapper = this.querySelector('.spell-meta-wraper');
let spellBanner = this.querySelector('.spell-banner');
//spellBanner is the svg I'm trying to animate
//Close
if (cardContent.style.display === "block") {
cardContent.style.display = "none";
metaWrapper.style.display = "none";
cardContent.style.height = "0px";
cardBackground.style.height = "95px";
//Open
} else {
cardContent.style.display = "block";
metaWrapper.style.display = "block";
cardContent.style.height = "410px";
cardBackground.style.height = "505px";
anime({
targets: spellBanner,
points: [
{ value: 'M0,0h47v156l-23.5-21.14L0,156V0z' }
],
easing: 'easeOutQuad',
duration: 2000,
loop: true
});
}
});
}
It might be useful to point out that I'm trying to do this in wordpress, and the cards I'm trying to edit come from a while loop.
I have tried changing the "points" attribute to "d", but that didn't work. I also tested the "spellBanner" variable to see if it's referencing the right element, and it does. I also checked the page's source to see if wordpress is loading the anime.min.js script, and it is.
I have no idea what I'm doing wrong or what alternatives I have for lving this problem.