Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pub
frama-c
Commits
d137ac9a
Commit
d137ac9a
authored
2 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome/dnd] continuous meta
parent
4290f4d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/dome/renderer/newdnd.tsx
+29
-2
29 additions, 2 deletions
ivette/src/dome/renderer/newdnd.tsx
with
29 additions
and
2 deletions
ivette/src/dome/renderer/newdnd.tsx
+
29
−
2
View file @
d137ac9a
...
@@ -112,8 +112,13 @@ interface DropZone extends DropHandler {
...
@@ -112,8 +112,13 @@ interface DropZone extends DropHandler {
*/
*/
export
class
DnD
{
export
class
DnD
{
constructor
()
{
this
.
handleKey
=
this
.
handleKey
.
bind
(
this
);
}
private
registry
=
new
Map
<
string
,
DropZone
>
();
private
registry
=
new
Map
<
string
,
DropZone
>
();
private
dragging
:
HTMLElement
|
undefined
;
private
dragging
:
HTMLElement
|
undefined
;
private
dropping
:
Dropping
|
undefined
;
private
hovering
:
DropZone
|
undefined
;
private
hovering
:
DropZone
|
undefined
;
onDropZone
(
zone
:
DropZone
):
string
{
onDropZone
(
zone
:
DropZone
):
string
{
...
@@ -130,6 +135,9 @@ export class DnD {
...
@@ -130,6 +135,9 @@ export class DnD {
handleStart
(
node
:
HTMLElement
):
void
{
handleStart
(
node
:
HTMLElement
):
void
{
this
.
dragging
=
node
;
this
.
dragging
=
node
;
const
body
=
document
.
body
;
body
.
addEventListener
(
'
keyup
'
,
this
.
handleKey
);
body
.
addEventListener
(
'
keydown
'
,
this
.
handleKey
);
}
}
handleEvent
(
e
:
DraggableEvent
):
void
{
handleEvent
(
e
:
DraggableEvent
):
void
{
...
@@ -146,19 +154,38 @@ export class DnD {
...
@@ -146,19 +154,38 @@ export class DnD {
const
curr
=
this
.
hovering
;
const
curr
=
this
.
hovering
;
if
(
hover
!==
curr
)
{
if
(
hover
!==
curr
)
{
this
.
hovering
=
hover
;
this
.
hovering
=
hover
;
if
(
curr
&&
curr
.
onDropOut
)
{
curr
.
onDropOut
();
}
if
(
curr
&&
curr
.
onDropOut
)
{
this
.
dropping
=
undefined
;
curr
.
onDropOut
();
}
}
}
if
(
hover
&&
hover
.
onDropIn
)
{
if
(
hover
&&
hover
.
onDropIn
)
{
const
meta
=
e
.
altKey
||
e
.
ctrlKey
||
e
.
shiftKey
||
e
.
metaKey
;
const
meta
=
e
.
altKey
||
e
.
ctrlKey
||
e
.
shiftKey
||
e
.
metaKey
;
const
rect
=
hover
.
node
.
getBoundingClientRect
();
const
rect
=
hover
.
node
.
getBoundingClientRect
();
const
dropX
=
Math
.
round
(
e
.
clientX
-
rect
.
left
);
const
dropX
=
Math
.
round
(
e
.
clientX
-
rect
.
left
);
const
dropY
=
Math
.
round
(
e
.
clientY
-
rect
.
top
);
const
dropY
=
Math
.
round
(
e
.
clientY
-
rect
.
top
);
hover
.
onDropIn
({
meta
,
rect
,
dropX
,
dropY
});
const
d
=
this
.
dropping
=
{
meta
,
rect
,
dropX
,
dropY
}
hover
.
onDropIn
(
d
);
}
}
}
handleKey
(
e
:
KeyboardEvent
):
void
{
const
callback
=
this
.
hovering
?.
onDropIn
;
const
drop
=
this
.
dropping
;
if
(
callback
&&
drop
)
{
const
meta
=
e
.
altKey
||
e
.
ctrlKey
||
e
.
shiftKey
||
e
.
metaKey
;
if
(
meta
!==
drop
.
meta
)
{
drop
.
meta
=
meta
;
callback
(
drop
);
}
}
}
}
}
}
handleDrop
():
void
{
handleDrop
():
void
{
const
body
=
document
.
body
;
body
.
removeEventListener
(
'
keyup
'
,
this
.
handleKey
);
body
.
removeEventListener
(
'
keydown
'
,
this
.
handleKey
);
this
.
dragging
=
undefined
;
this
.
dragging
=
undefined
;
const
target
=
this
.
hovering
;
const
target
=
this
.
hovering
;
if
(
target
)
{
if
(
target
)
{
...
...
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