Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

74
Visualizações
Arrows stucking

I'm building moving machine-part with three arrows moving on axes. Every arrow has its own angle. 3 checkbox and 4 buttons. Pressing on the first button moves arrow 20 degree to the right, second 20 degree to the right. Third moves arrow to the left, fourth moves arrow to the right. The problem is: after few rounds pressing on the first or second button stops moving an arrow. Don't know why does it happen.

Here I link check boxes to the arrows

const handleChangeButton=(buttonName)=>{  
  switch (buttonName) {
    case 'turret':
      setSelectedButton('turret')
      console.log(buttonName)
      break;
    case 'lazer':
      setSelectedButton('lazer')
      console.log(buttonName)
      break;
    case 'lezerr':
      setSelectedButton('lezerr')
      console.log(buttonName)
      break;  
  }
}
  const changeButtonToTurret=()=>{
    props.handleChangeButton('turret')
  
  }
  const changeButtonToLazer=()=>{
    props.handleChangeButton('lazer')
  
  }
  const changeButtonTorad=()=>{
    props.handleChangeButton('lezerr')
  
  }

Here I give a new angle and insert the three different angles of each arrow

 const handleChange=(e)=>{
 let curretnAngle=(e.target.valueAsNumber);
   if (props.selectedButton=='turret') {
     curretnAngle=props.angleTurret;
   }
   else if (props.selectedButton=='lazer') {
      curretnAngle=props.angleLazer;
   } 
   else{
     curretnAngle=props.radanglee;
   }

And here I lower and raise the new angle 20 degrees

    switch (e.target.name){
      case 'minus':
          props.handlerotate(curretnAngle-=20)
          break;
      case 'plus':
          props.handlerotate(curretnAngle+=20)
          break;
    }
  }

This is how the angle of each arrow knows to move through the new angle 20 degrees right and left

The picture of the simulation = : https://i.stack.imgur.com/JfHgo.png

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda