This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
old
宇天 2019-08-22 18:36:22 +08:00
parent 189253f2df
commit 4e1d3ea10b
2 changed files with 41 additions and 7 deletions

View File

@ -4,14 +4,47 @@
* @date 2019/08/21 17:28:40 * @date 2019/08/21 17:28:40
*/ */
"use strict"; 'use strict'
export default Drag { import { bind, unbind } from '../utils'
constructor(elem){
const log = console.log
const DEF_OPT = {
axis: '', // x | y | xy 拖拽方向
limit: false, // false | window | parent 拖拽范围
overflow: true // 是否可拖拽出可视区外
}
export default class Drag {
constructor(elem) {
this.$elem = elem this.$elem = elem
} }
by(node){ // drag by
by(node, opt = {}) {
this.$drag = node
this.opt = Object.assign(Object.create(null), DEF_OPT, opt)
//
if (this.opt.limit !== false) {
this.opt.overflow = false
}
// 鼠标状态图标
var ico = document.documentMode ? 'move' : 'grab'
if (window.sidebar) {
ico = '-moz-' + ico
} else {
ico = '-webkit-' + ico
}
this.$drag.style.cursor = ico
bind(this.$drag, 'mousedown', ev => {
var bcr = this.$elem.getBoundingClientRect()
log(bcr)
})
return this
} }
} }

View File

@ -112,7 +112,7 @@
</style> </style>
<script> <script>
import '../drag/index' import Drag from '../drag/core'
import { nextTick, bind, unbind, clickOutside } from '../utils' import { nextTick, bind, unbind, clickOutside } from '../utils'
@ -634,6 +634,7 @@ const _layer = {
l.setAttribute('mask', '') l.setAttribute('mask', '')
l.innerHTML = '<p>ffdfdffd</p>' l.innerHTML = '<p>ffdfdffd</p>'
document.body.appendChild(l) document.body.appendChild(l)
new Drag(l.root.children[1]).by(l.__TITLE__)
return _layer.open(opt) return _layer.open(opt)
}, },
confirm(content, title, yescb, nocb) { confirm(content, title, yescb, nocb) {