Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
vue - transform rotate doesn't rotate back when toggle state

When I click the button, the state showMore will be toggled. enter image description here

If I click it at the first time, it rotates as expected.
But when I click again the button, the animation doesn't works.

App.vue

<template>
  <div class="item">
    <button class="learn-more-btn" @click="toggleShow">
      <span>Rotate</span>
      <img
        src="./assets/logo.png"
        alt="arrow"
        :class="arrowLeft"
        width="50"
        height="50"
      />
    </button>
  </div>
</template>
<script>
export default {
  components: {},
  data() {
    return {
      showMore: false,
    };
  },
  methods: {
    toggleShow() {
      this.showMore = !this.showMore;
    },
  },
  computed: {
    arrowLeft() {
      let arrow = "turn-arrow";
      if (this.showMore === true) {
        return arrow;
      }
      return true;
    },
  },
};
</script>
<style scoped lang="scss">
.item {
  display: flex;
  border: 1px solid grey;
  width: 150px;
  .learn-more-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    border: none;
    &:hover {
      cursor: pointer;
    }
    img {
      display: inline-block;
    }
    .turn-arrow {
      -moz-transform: rotate(180deg);
      -ms-transform: rotate(180deg);
      -webkit-transform: rotate(180deg);
      transform: rotate(180deg);
      transition: all 3000ms;
    }
    span {
      padding: 0 0.5rem;
    }
  }
}
</style>

Codesandbox:
https://codesandbox.io/s/headless-fire-ng001?file=/src/App.vue

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I just refactored your code a little bit and simplified things.

Instead of using transitions I replaced them with animations and toggled between .rotate-down and .rotate-up classes which use this animations.

Check it out: https://codesandbox.io/s/wonderful-wescoff-icnnm?file=/src/App.vue

Hope it's helpful :)!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda