1.0.4 • Published 2 years ago

animate-popup v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

animate-popup

组件介绍

animate-popup是一个弹窗组件,实现了ios15沉浸式的弹窗效果; 引入组件,自动完成背景缩放效果,详见下图: https://xydideo.gitee.io/blog/public-image/animate-popup.gif

组件依赖

vue3、vant4、less

组件使用

  1. 在main.js中引入并组册
import AnimatePopup from 'animate-popup'
import "animate-popup/style.css"
app.use(AnimatePopup)

// 或者页面中局部注册
// import { AnimatePopup } from 'animate-popup'
// import "animate-popup/style.css"
  1. 在index.html 的 app 元素添加一个根目录
<!-- 解决fixed跟transform的问题 -->
<div>
    <div id="app"></div>
</div>
  1. 模板中使用demo示例
<template>
  <div>
    <div @click="isShow=true">点击弹窗组件</div>
    <animate-popup v-model:isShow="isShow" title="弹窗标题" :isScaleAni="true" :close-on-click-overlay="false">
      <!-- 弹窗内容插槽 -->
      <template #main>
        <div>
          弹窗的内容
        </div>
      </template>
    </animate-popup>
  </div>
</template>

<script setup>
import { ref } from 'vue'
// 控制组件的显示否
const isShow = ref(false)
</script>

组件api

Props

参数说明类型默认值
isShow是否显示弹窗Booleanfalse
height弹窗高度String96vh
title弹窗标题String
isScaleAni是否需要沉浸式ios交互Booleantrue

组件重置

如果想修改app弹层,可以重置样式

.app-scale-class {
  transform: translateY(-3vh) scale(0.9);
  transform-origin: top;
  opacity: 0.5;
  border-radius: 20px;
  overflow: hidden;
}

其他

app默认设置样式为:

#app{
  transition: all ease 300ms;
  font-size: 14px;
  background: #fff;
}

全局样式类名为: .app-scale-class,.body-scale-class,.popup-main

其中popup-main为弹窗版心内容

.popup-main {
  height: 100%;
  .popup-content {
    overflow: scroll;
  }
}
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago