在vue.js中制作徽标动画

r7knjye2  于 2023-10-23  发布在  Vue.js
关注(0)|答案(1)|浏览(111)

我试图在vue.js中动画一个徽标,当你将指针移动到徽标上时。它应该是一个'点'的测量下面,应该移动一次的行动都向下和向上。我设法使它出现在底部,但它只是眨眼,而不是顺利的动画。
下面是我尝试的代码:

<circle id="Ellipse_2" data-name="Ellipse 2" cx="92.995" cy="8.495" r="3.995"  fill="#c5a075">
    <animate attributeName="cy"
        dur="3s"
        calcMode="spline"
        repeatCount="indefinite"
        values="8.495; 52.779; 8.495"
        keySplines="0 0 1 1"
        keyTimes="0;0.5;1"/>
    </circle>

谢谢你,谢谢!

kmpatx3s

kmpatx3s1#

你可以为你的logo和动画创建一个Vue组件。您可以通过在JavaScript文件(例如Logo.vue)中定义Vue组件并将其链接到HTML来实现这一点。
Logo.vue:

<template>
  <div class="logo-container" @mouseover="animateDot">
    <div class="logo">
      <!-- Your logo SVG code goes here -->
    </div>
    <transition name="dot-animation">
      <div v-if="showDot" class="dot"></div>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showDot: false,
    };
  },
  methods: {
    animateDot() {
      this.showDot = true;
      setTimeout(() => {
        this.showDot = false;
      }, 3000); // Adjust the duration as needed (3 seconds in this example)
    },
  },
};
</script>

<style scoped>
.logo-container {
  position: relative;
}

.dot-animation-enter-active,
.dot-animation-leave-active {
  transition: all 3s ease-in-out; /* Adjust the duration as needed */
}

.dot-animation-enter-to,
.dot-animation-leave-to {
  opacity: 0;
  transform: translateY(-100%);
}

.dot {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px; /* Adjust the size of your dot */
  height: 8px; /* Adjust the size of your dot */
  background-color: #c5a075;
  border-radius: 50%;
}
</style>

现在你可以把它放在任何你想放的地方。

相关问题