In the process of developing my VueJS project, I have successfully implemented a series of cards on the page. However, I am now facing a challenge - when a user selects one of these cards, I want it to move to the center of the screen while maintaining its original position in the list.
I know that by changing the position property from 'unset'
to 'relative'
, I can give the card movement functionality using properties like 'left'
and 'top'
. But, I need a solution that will automatically center the selected card regardless of its initial position on the screen.
Is there anyone out there who knows how to achieve this using JavaScript?
My intuition tells me that it should be possible to retrieve the current location of the node and then move it to the center of the screen, but I'm not certain about the exact steps needed to make this happen...
For better understanding, here is an image showcasing the situation: CardsProject
UPDATE: As a temporary solution, I have decided to set an absolute position for the card. This method, however, eliminates any CSS transition effect from the card's original position to the center of the screen, causing the card to temporarily lose its place within the deck.
Image before click: click here for image
Image after click: click here for image