I’m attempting to trick a Pro Gallery called #gallery2 into collapsing when a 1x1 pixel image titled “Blank” is set as a gallery image.
I have a dynamic page, but not every project has an image, so I want the large space where the gallery is to collapse.
Hey! I have basically the same thing setup on my site. I have my gallery in a strip, and when there are no images in the gallery database field I have the strip collapse with the following code.
You could remove the “blank” image and just leave the field empty and this should work.
import wixData from 'wix-data';
$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
var item = $w("#dynamicDataset").getCurrentItem();
if (item["your field title"] === undefined)
$w("#extensionStrip").collapse();
else $w("#extensionStrip").expand();
});
});
Hey thanks a lot! This worked.
Follow up question, I think since I’m using this on a dynamic page, after the strip collapses, a strip following moves upward to take it’s place, but the footer doesn’t come with it, so there’s a large void about the size of the gallery at the page bottom.
Do dynamic pages have a static height even when something collapses? Maybe I’m doing something wrong though because on a different page (although not a dynamic page) I have a collapsing element at the top and the rest of the page tends to shift up or down accordingly including the footer.
@jmarsh4087 Glad to hear it’s working! I don’t think dynamic pages have any sort of height regulations (it doesn’t do this anywhere for me), but I know the standard rule is that if there is a distance greater than 70px between elements (like the footer and the next strip) then things won’t collapse properly.
@lmeyer I didn’t know the 70 px rule, but I have experienced it so I always try to make the strips touch. At the end I can’t get any closer than 20 px from the last strip to the footer, but it still follows the rule.
I tried cut/pasting the whole page, but for some reason it still won’t work.
@jmarsh4087 I would double check to make sure that all the elements on the collapsing strip are attached to the strip. Sometimes an element can be sitting on a strip but not attached to it. Move it off the strip or container and drag it back in again until you see the “ATTACH HERE” message.
@lmeyer Made sure the gallery pro sits inside of the collapsing strip. I can tell it works because the bottom strip comes up towards the top meaning the gallery is collapsed in between.
I have tried:
cut/paste every element on the whole page individually
cut all 4 strips at once, reduce overall page size, then paste and adjust
use zoom out mode to reorder the strips in various orders, I can tell they are shuffling when I publish, but the white space is still at the bottom
I’m thinking of opening up a ticket with Wix support so they can go into it.