From 9ba1ea6933c7b5dfe52d5f6512d2d118cb39e77a Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 1 Jun 2018 10:38:27 +0800 Subject: [PATCH] perf[el-dragDialog]: add dragDialog callback function --- src/directive/el-dragDialog/drag.js | 5 ++++- src/views/components-demo/dragDialog.vue | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/directive/el-dragDialog/drag.js b/src/directive/el-dragDialog/drag.js index 3e3fb62a..68e08523 100644 --- a/src/directive/el-dragDialog/drag.js +++ b/src/directive/el-dragDialog/drag.js @@ -1,5 +1,5 @@ export default{ - bind(el, binding) { + bind(el, binding, vnode) { const dialogHeaderEl = el.querySelector('.el-dialog__header') const dragDom = el.querySelector('.el-dialog') dialogHeaderEl.style.cssText += ';cursor:move;' @@ -63,6 +63,9 @@ export default{ // 移动当前元素 dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;` + + // emit onDrag event + vnode.child.$emit('dragDialog') } document.onmouseup = function(e) { diff --git a/src/views/components-demo/dragDialog.vue b/src/views/components-demo/dragDialog.vue index 3eb9bd91..454d6327 100644 --- a/src/views/components-demo/dragDialog.vue +++ b/src/views/components-demo/dragDialog.vue @@ -1,7 +1,11 @@