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
d12917a2
Commit
d12917a2
authored
2 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Write more documentation
parent
79ec1b9d
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
docs/guide/index.md
+63
-0
63 additions, 0 deletions
docs/guide/index.md
with
63 additions
and
0 deletions
docs/guide/index.md
+
63
−
0
View file @
d12917a2
...
@@ -144,6 +144,69 @@ function randomKey(element) {
...
@@ -144,6 +144,69 @@ function randomKey(element) {
This method changes the key of a moved item to a random string if the key has a length of 1.
This method changes the key of a moved item to a random string if the key has a length of 1.
This is used inside example 2 (the tic-tac-toe game).
This is used inside example 2 (the tic-tac-toe game).
## Functional item properties
Properties of items don't have to be Numbers, Strings and Objects, they can also be functions
returning those types. They will automatically be called with a grid object containing the
`gridId`
as well as the
`context`
.
A singular item could look like this:
```
javascript
[{
x
:
(
grid
)
=>
{
return
grid
.
gridId
===
"
lesson-plan
"
?
this
.
lesson1X
:
0
;
},
y
:
(
grid
)
=>
{
return
grid
.
gridId
===
"
lesson-plan
"
?
this
.
lesson1Y
:
0
;
},
w
:
1
,
h
:
this
.
lesson1Length
,
key
:
"
lesson1
"
,
data
:
{
text
:
this
.
lessonData
.
lesson1
,
},
}]
```
Items can also have custom extra properties. They will however be reset after moving.
An example where these are used is Example 5.
## Listening to grid changes
There are two ways to process changes made by dragging and dropping items: the
`input`
event
and the
`itemChanged`
event.
The
`input`
event works together with the value prop so one can use
`v-model`
to supply the grid
and have changes made automatically. The event returns the grid how it would look if the item
moved to the specific location.
::: warning
Notice that this event is only possible if your item properties are basic types, functional items are not
supported and the properties will be reset to
`undefined`
.
:::
The
`itemChanged`
event returns the moved item with following attributes:
```
javascript
let
eventData
=
{
context
:
String
,
// Context of the origin grid (same as the target's)
data
:
Object
,
// Data Object of the item
gridId
:
String
,
// ID of the target grid
h
:
Number
,
// Height of the item
key
:
String
,
// Key of the item
mouseX
:
Number
,
// Mouse position on the element relative to
mouseY
:
Number
,
// the center of the top left rectangle
originGridId
:
String
,
// ID of the origin grid
w
:
Number
,
// Width of the item
x
:
Number
,
// New x position (col) of the item
y
:
Number
,
// New y position (row) of the item
}
```
This event doesn't change the grid, this change has to be made separately. This is
useful if e.g. a direct API request is needed.
## Multiple grids
## Multiple grids
To connect multiple grids they need to have the same context. If you supply the same string to the
To connect multiple grids they need to have the same context. If you supply the same string to the
...
...
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