Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vue-draggable-grid
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
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
vue-draggable-grid
Commits
a733304f
Commit
a733304f
authored
2 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Display highlight
parent
2fe0f9fd
No related branches found
No related tags found
1 merge request
!2
Resolve "Implement basic functionality"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Grid.vue
+32
-6
32 additions, 6 deletions
src/Grid.vue
with
32 additions
and
6 deletions
src/Grid.vue
+
32
−
6
View file @
a733304f
<
template
>
<
template
>
<div
@
dragover.prevent
@
drop.prevent=
"handleDrop"
class=
"grid"
>
<div
@
dragover.prevent=
"handleDragOver"
@
drop.prevent=
"handleDrop"
class=
"grid"
>
<slot
name=
"highlight"
>
<slot
name=
"highlight"
>
<div
id=
"highlight"
></div>
<div
id=
"highlight"
ref=
"highlight"
></div>
</slot>
</slot>
<DragContainer
<DragContainer
v-for=
"item in items"
v-for=
"item in items"
...
@@ -35,7 +39,19 @@ export default {
...
@@ -35,7 +39,19 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
handleDragOver
(
event
)
{
let
data
=
event
.
dataTransfer
.
getData
(
"
vueDrag/gridItem
"
);
let
element
=
JSON
.
parse
(
data
);
let
coords
=
this
.
getCoords
(
event
.
layerX
,
event
.
layerY
);
this
.
$refs
.
highlight
.
style
.
display
=
"
block
"
;
this
.
$refs
.
highlight
.
style
.
gridColumnStart
=
coords
.
x
+
""
;
this
.
$refs
.
highlight
.
style
.
gridRowStart
=
coords
.
y
+
""
;
this
.
$refs
.
highlight
.
style
.
gridColumnEnd
=
"
span
"
+
element
.
w
;
this
.
$refs
.
highlight
.
style
.
gridRowEnd
=
"
span
"
+
element
.
h
;
},
handleDrop
(
event
)
{
handleDrop
(
event
)
{
this
.
$refs
.
highlight
.
style
.
display
=
"
none
"
;
let
data
=
event
.
dataTransfer
.
getData
(
"
vueDrag/gridItem
"
);
let
data
=
event
.
dataTransfer
.
getData
(
"
vueDrag/gridItem
"
);
let
element
=
JSON
.
parse
(
data
);
let
element
=
JSON
.
parse
(
data
);
console
.
log
(
element
);
console
.
log
(
element
);
...
@@ -45,12 +61,17 @@ export default {
...
@@ -45,12 +61,17 @@ export default {
}),
}),
1
1
);
);
element
.
x
=
let
coords
=
this
.
getCoords
(
event
.
layerX
,
event
.
layerY
);
1
+
Math
.
trunc
(
event
.
layerX
/
(
event
.
target
.
offsetWidth
/
this
.
cols
));
element
.
x
=
coords
.
x
;
element
.
y
=
element
.
y
=
coords
.
y
;
1
+
Math
.
trunc
(
event
.
layerY
/
(
event
.
target
.
offsetHeight
/
this
.
rows
));
this
.
items
.
push
(
element
);
this
.
items
.
push
(
element
);
},
},
getCoords
(
x
,
y
)
{
return
{
x
:
Math
.
ceil
(
x
/
(
this
.
$el
.
offsetWidth
/
this
.
cols
)),
y
:
Math
.
ceil
(
y
/
(
this
.
$el
.
offsetHeight
/
this
.
rows
)),
};
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -68,6 +89,11 @@ export default {
...
@@ -68,6 +89,11 @@ export default {
#highlight
{
#highlight
{
background
:
darkgrey
;
background
:
darkgrey
;
border
:
grey
dashed
2px
;
border
:
grey
dashed
2px
;
display
:
none
;
transition
:
all
2s
ease-in-out
;
z-index
:
-1
;
pointer-events
:
none
;
user-select
:
none
;
}
}
.grid
{
.grid
{
...
...
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