Lots of panels (product) are showing in a page in multiple row and multiple column. I'm using Vue 2 and panels are components. Now, on clicking a panel, I want to show details of that panel below the row of that. This is similar to Google image search.
For example, in the above image, if I click any of the s1, s2 or s3, the big panel will appear after s3 (last element of that row). Similarly, for clicking s4 or s5, the big panel appear after s5.
** Number of items in a row will vary based on the screen size.
How to find the last element of the row and insert a component after that element?
If you want to arrange the components: one will appear after another. Let me assume I have all those components in an array and you can re-arrange those in the array as par your logic, and you can use special attribute: is to render those component.
Here in sample I have an array of components and I use
v-for
to render those one after another:See fiddle here.
HTML:
JS:
This does not answer your question directly, but should implement the expected behavior. Here is a jsfiddle
Template:
Vue:
Scss: