I would like to achieve the following with kirby: My site’s main content container is split up into two sections (using flexbox), one contains the thumbnails of all projects in the backend (this section takes up 75% of the site’s width), the other section, which is sitting on the righthand site of the projects container, should display the title + the description of the project which the user is hovering over. When hovering over no project at all it should remain empty. Here’s a quick mockup of the layout and the functionality I’m describing:
Right now, I am only getting so far that I can display the project’s title and description right above the project’s thumbnail, in the same div, which obviously is quite simple:
You can make an Ajax request that fetches the information from the server when the user hovers over the image or clicks on it and injects it into the div.
Add the caption to each .project-entry and hide it with css in that scope. Then use javascript to make it visible in the page on .project-entry hover. This should give you some hints (untested jQuery code):
$(".projects-container").on("mouseover", ".project-entry", function () {
$(".project-info-container").html($(this).find(".showcase-caption").html());
});
PS: I would see this as an excellent case for progressive enhancement: show the captions in each .project-entry when no js is available. When there is js available, hide them with css in the project-entry scope and use method as shown above.
Nice, your suggestion works well already. The project title and description are both showing up in the div I intended for them. When showing the content of .showcase-caption using mouseover, I should be able to hide it again as well with mouseleave, right? How can I implement that in your script?
Hm not quite working yet. First I thought it was because a couple of brackets were mixed up, but it didn’t solve it. With this code, nothing is showing up at all when hovering: