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

123
Visualizações
I have items arranged in a circle. How can I rotate the whole thing while keeping the inside elements upright?

Im using code based off of this demo (https://codepen.io/KittyGiraudel/pen/vEJXGm) in order to arrange a few items in a circle. I want create an animation to rotate the circle however keep the elements inside upright as it rotates.

So I thought I could use simple jQuery to do a css "transform: rotate()" and then use the same thing with a negative rotation on the elements inside, however because of the way the demo is set up, the inner elements are moved to the center of the whole circle when rotated.

$('.button').click(function() {
  $('.box').animate(
    { deg: 72 },
    {
      duration: 1200,
      step: function(now) {
        $(this).css({ transform: 'rotate(' + now + 'deg)' });
      }
    }
  );
});

Alternatively, is there a way to use jQuery to change the value of the "$rot" variable? I sass variables can't be accessed by js but maybe there is a workaround?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Since JS is not blocking, I would suggest to simply rotate your inner elements in the opposite direction of your main rotation. It would look something like this:

$('.button').click(function() {
  $('.box').animate(
    { deg: 72 },
    {
      duration: 1200,
      step: function(now) {
        $(this).css({ transform: 'rotate(' + now + 'deg)' });
      }
    }
  );
  $('.box .inner').animate(
    { deg: -72 },
    {
      duration: 1200,
      step: function(now) {
        $(this).css({ transform: 'rotate(' + now + 'deg)' });
      }
    }
  );
});

Using the codepen you submitted, I modified it a bit for you to see what would be the actual result.

https://codepen.io/Dvermette018/pen/podGmXR

Dave

about 4 years ago · Juan Pablo Isaza Relatório
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