1.0.15 • Published 2 months ago

suspend-vue v1.0.15

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

组件介绍

  1. suspend-vue 是一个能够任意拖动的组件,内部可放任意元素
  2. 它同时适用于移动端和 PC 端
  3. 且它具有吸附效果
  4. 具有自定义指令等多种使用方式
  5. 如果对该组件有任何意见,可发送至934772615@qq.com

组件使用

安装

npm i suspend-vue

yarn add suspend-vue

引入

  1. 全局引入
import {createApp} from 'vue'
import App from './App.vue'
import SuspendPlugin from 'suspend-vue'

const app = createApp(App)
app.use(SuspendPlugin)
  1. 组件内引入
<script lang="ts" setup>
	import { Suspend } from 'suspend-vue'
</script>

使用示例

组件模式

<template>
	<Suspend>
    	xxx
  </Suspend>
</template>

<script lang="ts" setup>
	import { Suspend } from 'suspend-vue'
</script>

指令模式

<template>
    <div v-suspend>
        这是一段测试文本  
    </div>
</template>

<script lang="ts" setup>
</script>

组件属性

属性用途默认值
adsorption是否开启吸附贴边功能,{x: false, y:false}
defaultSite设置其初始坐标,xy分别表示盒子的lefttop 初始值( 默认单位为px,目前仅支持px,rem,vw,vh,支持负数){x: '', y: ''}
zIndex设置层级999
contentMove点击 slot 内容区域是否可以拖动flase
delay动画时长,为 0 时则关闭动画,单位 ms300
absolute开启后,设置盒子宽高,即可控制其可滑动区域false
model使用模式,window(对话窗口模式) | defaultdefault

组件方法

事件用途返回值
moveStart在该组件刚开始移动时会触发的事件
moveEnd在组件移动结束时会触发的事件

指令回调函数

事件用途返回值
click点击事件event
moveStart该组件刚开始移动时会触发的事件void
moveEnd在组件移动结束时会触发的事件void

Q&A

Q:拖拽时会触发点击事件

A:

  • 组件形式在 v1.0.8 版本修复了这个问题
  • 指令形式会触发元素本身的点击事件,目前还没找到比较好的解决方法,可以通过回调函数的形式使用v-suspend="{click: onclick}"

更多内容敬请期待

1.0.15

2 months ago

1.0.14

2 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago