We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Model not responding to parent UI button clicks after load

Home Forums General Questions Model not responding to parent UI button clicks after load

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #87485
    3dma
    Customer

    Hi guys! For some reason, after loading, the model sometimes not responding to parents html UI button clicks. After refresh page, it starts working most time

    The buttons are injected into the parent index.html page only once on initial load from Webflow CMS depending on a URL query parameter.

    Do you have any ideas as to what might be causing this and how it can be fixed?

    Video Link

    #87493

    Hi,
    I’d suggest inserting print to console to verify that:

    1) Elements are present when you start your Puzzles.
    2) Actual event listeners got registered on the elements.
    3) Events were fired upon clicks.

    See here for more info.

    Soft8Soft Tech Chief
    Want more Verge3D updates? Follow me on X, Facebook, or LinkedIn

    #87505
    3dma
    Customer

    Hi Alexander, It seems that Verge loads first and doesn’t attach listeners to the buttons that appear later.

    Is there a way to add a loading/initialization delay inside Verge, within the puzzles?

    For now, I’ve managed to add a temporary fix to the index.html file

    <script>
      let lastButtonCount = 0;
      let stableChecks = 0;
    
      function startVergeWhenUIReady() {
        const iframe = document.querySelector(".model_component");
        const optionsReady = !!document.querySelector("#options-items");
        const buttonCount = document.querySelectorAll("[data-option-btn][id]").length;
    
        if (buttonCount > 0 && buttonCount === lastButtonCount) {
          stableChecks++;
        } else {
          stableChecks = 0;
          lastButtonCount = buttonCount;
        }
    
        if (iframe && iframe.dataset.src && optionsReady && buttonCount > 0 && stableChecks >= 3) {
          if (!iframe.getAttribute("src")) {
            iframe.setAttribute("src", iframe.dataset.src);
            console.log("3D iframe started after UI. Buttons:", buttonCount);
          }
          return;
        }
    
        setTimeout(startVergeWhenUIReady, 100);
      }
    
      window.Webflow = window.Webflow || [];
      window.Webflow.push(function () {
        setTimeout(startVergeWhenUIReady, 300);
      });
    </script>
    • This reply was modified 1 month ago by 3dma.
    #87509

    Hi,
    Delaying Verge3D page startup might not be the most efficient method to fix this issue. Instead you can try running the verge app normally, but send a message (with postMessage) to the iframe once the buttons are ready. In puzzles you can catch this message by using the on event of puzzle and attach all required event listeners in the do slot of this puzzle.

    Soft8Soft Tech Chief
    Want more Verge3D updates? Follow me on X, Facebook, or LinkedIn

    #87511
    3dma
    Customer

    Thanks for the suggestion!
    1. Could you please explain why delaying the Verge3D iframe startup is not the most efficient approach? In my quick test seems to prevent the issue, so I’d like to understand the possible downsides
    2. If possible could you please clarify deeper how the postMessage solution should look in Puzzles?
    I attached a screenshot of how I understood it. Is this structure correct? And if yes, does it mean I need to move all ~100+ click event puzzles there inside that do slot Or turn all of this in procedure to make list shorter?
    Thanks!

    Attachments:
    #87516

    When you load the main frame first, and iframed Verge3D app second, there is some time lost. By utilizing postMessage you can load both in parallel and delay registering event listeners then the elements will actually be available.

    Your snippet looks OK. If there are any issues, try to debug with print to console puzzle.

    Soft8Soft Tech Chief
    Want more Verge3D updates? Follow me on X, Facebook, or LinkedIn

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.