Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
圆滚滚核心
vue-element-admin
提交
afd255d5
V
vue-element-admin
项目概览
圆滚滚核心
/
vue-element-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
afd255d5
编写于
4月 29, 2018
作者:
P
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix[el-dargDialog]: fixed drag bug in IE
上级
b7c80793
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
12 deletion
+17
-12
src/directive/el-dragDialog/drag.js
src/directive/el-dragDialog/drag.js
+17
-12
未找到文件。
src/directive/el-dragDialog/drag.js
浏览文件 @
afd255d5
...
...
@@ -2,10 +2,16 @@ export default{
bind
(
el
,
binding
)
{
const
dialogHeaderEl
=
el
.
querySelector
(
'
.el-dialog__header
'
)
const
dragDom
=
el
.
querySelector
(
'
.el-dialog
'
)
dialogHeaderEl
.
style
=
'
cursor:move;
'
dialogHeaderEl
.
style
.
cssText
+=
'
;
cursor:move;
'
dragDom
.
style
.
cssText
+=
'
;top:0px;
'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const
sty
=
dragDom
.
currentStyle
||
window
.
getComputedStyle
(
dragDom
,
null
)
function
getStyle
(
dom
,
attr
)
{
if
(
dom
.
currentStyle
)
{
return
dom
.
currentStyle
[
attr
]
}
else
{
return
getComputedStyle
(
dom
,
false
)[
attr
]
}
}
dialogHeaderEl
.
onmousedown
=
(
e
)
=>
{
// 鼠标按下,计算当前元素距离可视区的距离
...
...
@@ -13,15 +19,15 @@ export default{
const
disY
=
e
.
clientY
-
dialogHeaderEl
.
offsetTop
// 获取到的值带px 正则匹配替换
let
styL
,
styT
let
styL
=
getStyle
(
dragDom
,
'
left
'
)
let
styT
=
getStyle
(
dragDom
,
'
top
'
)
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
if
(
sty
.
left
.
includes
(
'
%
'
))
{
styL
=
+
document
.
body
.
clientWidth
*
(
+
sty
.
left
.
replace
(
/
\%
/g
,
''
)
/
100
)
styT
=
+
document
.
body
.
clientHeight
*
(
+
sty
.
top
.
replace
(
/
\%
/g
,
''
)
/
100
)
if
(
styL
.
includes
(
'
%
'
))
{
styL
=
+
document
.
body
.
clientWidth
*
(
+
styL
.
replace
(
/
\%
/g
,
''
)
/
100
)
styT
=
+
document
.
body
.
clientHeight
*
(
+
styT
.
replace
(
/
\%
/g
,
''
)
/
100
)
}
else
{
styL
=
+
sty
.
left
.
replace
(
/
\p
x/g
,
''
)
styT
=
+
sty
.
top
.
replace
(
/
\p
x/g
,
''
)
styL
=
+
sty
L
.
replace
(
/
\p
x/g
,
''
)
styT
=
+
sty
T
.
replace
(
/
\p
x/g
,
''
)
}
document
.
onmousemove
=
function
(
e
)
{
...
...
@@ -30,8 +36,7 @@ export default{
const
t
=
e
.
clientY
-
disY
// 移动当前元素
dragDom
.
style
.
left
=
`
${
l
+
styL
}
px`
dragDom
.
style
.
top
=
`
${
t
+
styT
}
px`
dragDom
.
style
.
cssText
+=
`;left:
${
l
+
styL
}
px;top:
${
t
+
styT
}
px;`
// 将此时的位置传出去
// binding.value({x:e.pageX,y:e.pageY})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录