Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
f663b23b
Commit
f663b23b
authored
6 years ago
by
Pan
Browse files
Options
Downloads
Patches
Plain Diff
perf[el-dragDialog]: add the verification of moving edges
parent
afd255d5
Branches
develop
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/directive/el-dragDialog/drag.js
+29
-6
29 additions, 6 deletions
src/directive/el-dragDialog/drag.js
with
29 additions
and
6 deletions
src/directive/el-dragDialog/drag.js
+
29
−
6
View file @
f663b23b
...
@@ -4,6 +4,7 @@ export default{
...
@@ -4,6 +4,7 @@ export default{
const
dragDom
=
el
.
querySelector
(
'
.el-dialog
'
)
const
dragDom
=
el
.
querySelector
(
'
.el-dialog
'
)
dialogHeaderEl
.
style
.
cssText
+=
'
;cursor:move;
'
dialogHeaderEl
.
style
.
cssText
+=
'
;cursor:move;
'
dragDom
.
style
.
cssText
+=
'
;top:0px;
'
dragDom
.
style
.
cssText
+=
'
;top:0px;
'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
function
getStyle
(
dom
,
attr
)
{
function
getStyle
(
dom
,
attr
)
{
if
(
dom
.
currentStyle
)
{
if
(
dom
.
currentStyle
)
{
...
@@ -18,6 +19,18 @@ export default{
...
@@ -18,6 +19,18 @@ export default{
const
disX
=
e
.
clientX
-
dialogHeaderEl
.
offsetLeft
const
disX
=
e
.
clientX
-
dialogHeaderEl
.
offsetLeft
const
disY
=
e
.
clientY
-
dialogHeaderEl
.
offsetTop
const
disY
=
e
.
clientY
-
dialogHeaderEl
.
offsetTop
const
dragDomWidth
=
dragDom
.
offsetWidth
const
dragDomheight
=
dragDom
.
offsetHeight
const
screenWidth
=
document
.
body
.
clientWidth
const
screenHeight
=
document
.
body
.
clientHeight
const
minDragDomLeft
=
dragDom
.
offsetLeft
const
maxDragDomLeft
=
screenWidth
-
dragDom
.
offsetLeft
-
dragDomWidth
const
minDragDomTop
=
dragDom
.
offsetTop
const
maxDragDomTop
=
screenHeight
-
dragDom
.
offsetTop
-
dragDomheight
// 获取到的值带px 正则匹配替换
// 获取到的值带px 正则匹配替换
let
styL
=
getStyle
(
dragDom
,
'
left
'
)
let
styL
=
getStyle
(
dragDom
,
'
left
'
)
let
styT
=
getStyle
(
dragDom
,
'
top
'
)
let
styT
=
getStyle
(
dragDom
,
'
top
'
)
...
@@ -32,14 +45,24 @@ export default{
...
@@ -32,14 +45,24 @@ export default{
document
.
onmousemove
=
function
(
e
)
{
document
.
onmousemove
=
function
(
e
)
{
// 通过事件委托,计算移动的距离
// 通过事件委托,计算移动的距离
const
l
=
e
.
clientX
-
disX
let
left
=
e
.
clientX
-
disX
cons
t
t
=
e
.
clientY
-
disY
le
t
t
op
=
e
.
clientY
-
disY
// 移动当前元素
// 边界处理
dragDom
.
style
.
cssText
+=
`;left:
${
l
+
styL
}
px;top:
${
t
+
styT
}
px;`
if
(
-
(
left
)
>
minDragDomLeft
)
{
left
=
-
minDragDomLeft
}
else
if
(
left
>
maxDragDomLeft
)
{
left
=
maxDragDomLeft
}
// 将此时的位置传出去
if
(
-
(
top
)
>
minDragDomTop
)
{
// binding.value({x:e.pageX,y:e.pageY})
top
=
-
minDragDomTop
}
else
if
(
top
>
maxDragDomTop
)
{
top
=
maxDragDomTop
}
// 移动当前元素
dragDom
.
style
.
cssText
+=
`;left:
${
left
+
styL
}
px;top:
${
top
+
styT
}
px;`
}
}
document
.
onmouseup
=
function
(
e
)
{
document
.
onmouseup
=
function
(
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment