vue3 数据可视化大屏弹窗组件效果实例

vue3 数据大屏 项目开发中,需要弹窗组件,这里我们整理弹窗组件,并通过gsap补间动画给弹窗添加入场动画以及离场动画。

效果截图

vue3 数据可视化大屏弹窗组件效果实例

演示动画

组件代码

<template>
  <div>
    <div @click="show=true">
      <slot></slot>
    </div>
    <div class="popWin">
      <div class="popWinBg" v-if="show"></div>
      <div class="popWinMain" ref="popWinMain" v-if="show">
        <div class="titleBody" ref="titleBody">
          <span>{{ title }}</span>
        </div>
        <div class="popClose" ref="popClose" v-if="showInner" @click="getHide"></div>
        <div class="slot" v-if="showInner">
          <slot></slot>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

import gsap from 'gsap'

export default {
  data() {
    return {
      show: true,
      showInner: false
    }
  },
  components: {},
  computed: {},
  mounted() {
    this.getShow()
  },
  props: {
    title: {
      type: String,
      default() {
        return '标题';
      }
    }
  },
  methods: {
    getShow() {
      this.show = true
      gsap.to(this.$refs.popWinMain, {
        duration: 1, width: '85%', onComplete: () => {
          this.showInner = true
          this.$nextTick(() => {
            gsap.to(this.$refs.popClose, {
              duration: 1, transform: ' rotateX(180deg)', onComplete: () => {
                this.showInner = true
              }
            })
            gsap.to(this.$refs.titleBody, {
              duration: 1, top: 10, onComplete: () => {
                this.showInner = true
              }
            })
          })
        }
      })
    },
    getHide() {
      this.showInner = false
      gsap.to(this.$refs.titleBody, {
        duration: 1, opacity: 0, onComplete: () => {
          this.showInner = true
        }
      })
      this.$nextTick(() => {
        gsap.to(this.$refs.popWinMain, {
          duration: 1, width: '0%', onComplete: () => {
            this.show = false
          }
        })
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.popWinBg {
  position: fixed;
  z-index: 8;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: initial;
}

.titleBody {
  background: url("./assets/titlebg.png") center center no-repeat;
  width: 100%;
  height: 79px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  top: -100px;
  opacity: 1;
  z-index: 0;

  span {
    font-size: 36px;
    font-family: PangMenZhengDao;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 32px;
    text-shadow: 0px 2px 3px rgba(17, 20, 22, 0.31);
  }
}

.popWin {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  position: fixed;
  z-index: 10;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  pointer-events: none;

}

.popWinMain {
  pointer-events: initial;
  background: url("./assets/popbg.png") no-repeat;
  background-size: 100% 100%;
  position: relative;
  overflow: hidden;
  width: 0;
  max-width: 1642px;
  height: 92%;
  max-height: 1004px;
  z-index: 100;

  .slot {
    position: absolute;
    top: 80px;
    left: 30px;
    width: calc(100% - 60px);
    height: calc(100% - 100px);
    //background: red;
  }
}

.popClose {
  position: absolute;
  right: 10px;
  top: 10px;
  background: url("./assets/icon_close.png") no-repeat;
  width: 64px;
  height: 64px;
  background-size: 100% 100%;
  cursor: pointer;
  z-index: 1;
}
</style>

更新日志

2023年12月05日 v1.1

删除用不到的依赖

增加层级控制,默认最大值,避免层级太低被其他组件遮挡。

增加appendToBody,是否将组件插入到body中 默认true

更多数据可视化大屏弹窗

vue 酷炫可视化大屏弹窗

弹窗完整实例代码

当前完整演示实例代码下载

项目基于Vue3 vite js实现

相关文件下载地址
此资源需支付 ¥1 后下载
支付宝购买扫右侧红包码购买更优惠,如无法下载请联系微信:17331886870
喜欢
vue3 数据可视化大屏弹窗组件效果实例