-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(modal): 弹窗增加拖拽功能 * docs(modal): 增加文档示例 * chore(changelog): 拖拽功能增加 changelog * chore(modal): getMousePosition 逻辑重构,删除不需要的代码 * chore(modal): 阻止默认行为,防止拖拽文字触发浏览器默认拖拽行为引起的 bug --------- Co-authored-by: 07akioni <[email protected]>
- Loading branch information
1 parent
d7ca2e4
commit 11ee8fc
Showing
16 changed files
with
465 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { color2Class } from './color-to-class' | ||
export { formatLength } from './format-length' | ||
export { mergeClass } from './merge-class' | ||
export { rtlInset } from './rtl-inset' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { isArray, isString } from 'lodash-es' | ||
|
||
export function mergeClass( | ||
...args: Array<string | undefined | boolean | (string | undefined)[]> | ||
) { | ||
return args | ||
.reduce<Array<string | undefined>>((p, c) => { | ||
if (isString(c)) { | ||
p.push(c) | ||
} | ||
if (isArray(c)) { | ||
p.push(...c) | ||
} | ||
return p | ||
}, []) | ||
.filter(Boolean) | ||
.join(' ') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<markdown> | ||
# 可拖拽 | ||
|
||
有人需要,它便有了 | ||
</markdown> | ||
|
||
<script lang="ts"> | ||
import { useModal } from 'naive-ui' | ||
import { defineComponent, ref } from 'vue' | ||
export default defineComponent({ | ||
data() { | ||
const modal = useModal() | ||
function showDialogPreset() { | ||
modal.create({ | ||
title: 'Dialog 预设拖拽', | ||
draggable: true, | ||
preset: 'dialog', | ||
content: '无意义的内容....' | ||
}) | ||
} | ||
function showCardPreset() { | ||
modal.create({ | ||
title: 'Card 预设拖拽', | ||
draggable: true, | ||
preset: 'card', | ||
content: '无意义的内容....' | ||
}) | ||
} | ||
return { | ||
showModal1: ref(false), | ||
showModal2: ref(false), | ||
showModal3: ref(false), | ||
showModal4: ref(false), | ||
showCardPreset, | ||
showDialogPreset | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<n-flex> | ||
<n-button @click="showModal1 = !showModal1"> | ||
card 预设 | ||
</n-button> | ||
<n-button @click="showModal2 = !showModal2"> | ||
dialog 预设 | ||
</n-button> | ||
<n-button @click="showModal3 = !showModal3"> | ||
无预设 | ||
</n-button> | ||
<n-button @click="showDialogPreset"> | ||
dialog 预设[命令式 Api] | ||
</n-button> | ||
<n-button @click="showCardPreset"> | ||
card 预设[命令式 Api] | ||
</n-button> | ||
<n-button @click="showModal4 = !showModal4"> | ||
弹窗嵌套 | ||
</n-button> | ||
</n-flex> | ||
<n-modal | ||
v-model:show="showModal1" | ||
title="card 预设拖拽" | ||
preset="card" | ||
draggable | ||
:style="{ width: '800px' }" | ||
> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
</n-modal> | ||
<n-modal | ||
v-model:show="showModal2" | ||
title="dialog 预设拖拽" | ||
preset="dialog" | ||
draggable | ||
:style="{ width: '800px' }" | ||
> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
</n-modal> | ||
<n-modal | ||
v-model:show="showModal3" | ||
title="无预设拖拽" | ||
draggable | ||
:style="{ width: '800px' }" | ||
> | ||
<template #default="{ draggableClass }"> | ||
<div :style="{ background: '#fff', padding: '20px' }"> | ||
<h1 :class="draggableClass" :style="{ margin: 0 }"> | ||
自定义标题 | ||
</h1> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
<div>无意义的内容...</div> | ||
</div> | ||
</template> | ||
</n-modal> | ||
<n-modal | ||
v-model:show="showModal4" | ||
title="嵌套弹窗拖拽" | ||
preset="card" | ||
:draggable="{ sticky: false }" | ||
:style="{ width: '800px' }" | ||
> | ||
<n-button @click="showDialogPreset"> | ||
在开一个弹窗 | ||
</n-button> | ||
</n-modal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.