A
A
Andrey Vasilev2020-07-20 10:05:49
Vue.js
Andrey Vasilev, 2020-07-20 10:05:49

Change inline styles dynamically on hover over container?

Hello.
There is a container with elements, you need to update the inline styles for the elements when hovering over it.

section.about-fs(@mousemove="")
      div.about-rhombuse__item.about-rhombuse__anim(
        v-for="(anim, index) in 5"
        :class="'about-rhombuse__anim_' + (index + 1)"
        :style=""
        )
      div.content-wrap
        div.about-rhombuse__item.about-rhombuse__anim(
          v-for="(anim, index) in 5"
          :class="'about-rhombuse__anim_' + (index + 6)"
          :style=""
          )

Here's what the code looks like, removed everything from :style and from mousemove.
created an object with styles, then made a computed property and threw all the changes into :style - the result is 0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Vasilev, 2020-07-20
@Nolis

own:

section.about-fs(@mousemove="rhombAnim")
      div.about-rhombuse__item.about-rhombuse__anim(
        v-for="(anim, index) in 5"
        :class="'about-rhombuse__anim_' + (index + 1)"
        :style="rhombValue"
        )
      div.content-wrap
        div.about-rhombuse__item.about-rhombuse__anim(
          v-for="(anim, index) in 5"
          :class="'about-rhombuse__anim_' + (index + 6)"
          :style="rhombValue"
          )

data() {
    return {
      rhombValue: {}
    }
  },

methods: {
    rhombAnim(e) {
      const pageX = e.clientX,
        pageY = e.clientY
      this.rhombValue = {
        transform: "rotate(90deg) translateX(" + pageX/60 + "%) translateY(" + pageY/45 + "%)"
      }
    }
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question