webapp的菜单栏动效实现,vue+gsap

4 篇文章 1 订阅
  • 菜单栏的动效实现,仿美团app效果。
  • 用的是gsap
  • 明天的目标:学做Animated svg 研究了一下,复杂的动效实现还得靠ae,大致流程:sketch/ai->AE->Bodymovin导出lottie的json文件
    了解图标规范,用Lottie动画让图标落地
    动效设计合集-图标篇
    lottiefiles
    找完资料发现这块应该属于ui/ue/产品经理==?心里有点蛋蛋的疑惑。
    静态
    动效长这样↓↓↓
    注意点是白色的外圈会比黄色的图标部分移动的更高一点。
    在这里插入图片描述

在这里插入图片描述

跳动小图标的完整代码如下

<template>
  <div class="circle-box">
    <div ref="circleBorder" class="circle-border" />
    <div class="circle-conver" />
    <div ref="circleMain" class="circle-main" :class="isActive===1?'':'white'">
      <van-icon :name="isActive===1?iconActive:icon" color="#212526" />
    </div>
  </div>
</template>

<script>
import gsap from 'gsap'
export default {
  name: 'CircleIcon',
  props: {
    iconActive: {
      type: String,
      default: 'chat'
    },
    icon: {
      type: String,
      default: 'chat-o'
    },
    isActive: {
      type: Number,
      default: -1
    }
  },
  data() {
    return {
    }
  },
  watch: {
    isActive: {
      handler(val, oldVal) {
        if (val === 1) {
          this.up()
        } else if (val === -1) {
          this.down()
        }
      }
      // immediate: true,
      // deep: true
    }
  },
  mounted() {
    this.isActive === 1 ? this.up() : 0
  },
  methods: {
    up() {
      const { circleBorder, circleMain } = this.$refs
      gsap.to(circleBorder, { duration: 0.6, y: -22, ease: 'back.out(4)' })
      gsap.to(circleMain, { duration: 0.6, y: -14, ease: 'back.out(2)' })
    },
    down() {
      const { circleBorder, circleMain } = this.$refs
      gsap.to(circleBorder, { duration: 0.2, y: 0, ease: 'power1.in' })
      gsap.to(circleMain, { duration: 0.2, y: 0, ease: 'power1.in' })
    }
  }
}
</script>

<style lang="scss" scoped>
$max:80px;
.circle{
  &-box{
    position: relative;
    width: $max;
    height: $max + 8px;
  }
  &-border{
    width: $max;
    height: $max;
    box-sizing: border-box;
    border-radius: 50%;
    background: white;
    display: block;
    border: 1px solid #262626;
    position: relative;
    top: 0;
  }
  &-conver{
    display: block;
    background: white;
    width: $max +4;
    height: $max + 1;
    position: absolute;
    top:-1px;
    left: -2px;
    z-index: 22;
  }
  &-main{
    width: $max - $padding-xs;
    height: $max - $padding-xs;
    position: absolute;
    top: 0;
    left: $padding-xxs;
    border-radius: 50%;
    background: #F9DD68;
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
    &.white{
      background: white;
    }
  }
}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值