Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Can't control button appear time using external events in ReactJS

I'm trying to create a website in ReactJS but can't seem to be able to control button show time in model-viewer. I used to able to control button show time using this:

<script>
  const modelViewer = document.querySelector("model-viewer");
  const button = document.getElementById("arbutton");
  
  function checkagain() {
    if (modelViewer.modelIsVisible === true) {
        button.style.display = "block";
    }
    else {
        checkagain2 = setTimeout(showbutton, 5);
    }
  }
  function showbutton() {
    if (modelViewer.modelIsVisible === true) {
        button.style.display = "block";
    }
    else {
        checkagain1 = setTimeout(checkagain, 5);
    }
  } 
  modelViewer.addEventListener("load", function() {
    showbutton();
  });
</script>

From this link

And this is how I'm importing Model-Viewer in ReactJS:

<Helmet>
  <script
    type="module"
    src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"
    async
  />
</Helmet>

<model-viewer
  ar ar-modes="webxr scene-viewer quick-look"
  style={{width:"100%", height:"50vh"}}
  alt="Your model Loading"
  //shadow-intensity="1"
  environment-image="neutral"
  exposure="1"
  poster="https://modelviewer.dev/assets/poster-astronaut.png"
  camera-controls
  loading="eager"
  src="https://modelviewer.dev/shared-assets/models/NeilArmstrong.glb"
  enable-pan
>
<button id="arbutton" className="arbutton" slot="ar-button">๐Ÿ‘‹ Show AR</button>
</model-viewer>
about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!