Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gojs-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jlc
gojs-project
Commits
27ce9a22
Commit
27ce9a22
authored
Jun 25, 2024
by
jlc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:bug修改和细节优化
parent
18c4e3c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
imageNode.vue
src/stageAchievements/imageNode.vue
+18
-9
No files found.
src/stageAchievements/imageNode.vue
View file @
27ce9a22
...
...
@@ -48,6 +48,10 @@ var myDiagram: any;
const
dialogVisible
=
ref
(
false
)
const
changeModel
=
ref
(
true
)
// 计算偏移量变量
const
dragStartOffsetX
=
ref
()
const
dragStartOffsetY
=
ref
()
// 切换添加端口/标定点的形式
function
toggleDivs
(
value
:
boolean
)
{
changeModel
.
value
=
value
;
...
...
@@ -443,7 +447,13 @@ function initDiagram() {
{
click
:
function
(
e
)
{
e
.
diagram
.
commit
(
function
(
d
)
{
var
data
=
{};
var
data
=
{
key
:
"new node"
,
color
:
'aqua'
,
portArray
:
[],
markArray
:
[],
category
:
""
};
d
.
model
.
addNodeData
(
data
);
var
part
=
d
.
findPartForData
(
data
);
// 在ContextMenuTool中设置保存mouseDownPoint的位置
...
...
@@ -474,7 +484,10 @@ function initDiagram() {
"_buttonFillOver"
:
"skyblue"
,
},
new
go
.
Binding
(
"visible"
,
""
,
function
(
o
)
{
// 根据是否有可撤销的操作来决定是否可见
if
(
o
&&
o
.
diagram
)
{
return
o
.
diagram
.
commandHandler
.
canUndo
();
// 可以撤销返回true,否则返回false
}
return
false
;
}).
ofObject
()),
// 重做按钮
$
(
"ContextMenuButton"
,
...
...
@@ -485,7 +498,10 @@ function initDiagram() {
"_buttonFillOver"
:
"skyblue"
,
},
new
go
.
Binding
(
"visible"
,
""
,
function
(
o
)
{
// 根据是否有可重做的操作来决定是否可见
if
(
o
&&
o
.
diagram
)
{
return
o
.
diagram
.
commandHandler
.
canRedo
();
// 可以重做返回true,否则返回false
}
return
false
;
}).
ofObject
())
);
...
...
@@ -509,15 +525,13 @@ function initDiagram() {
);
}
// 导出画布中的节点和连线数据
function
exportData
()
{
if
(
myDiagram
)
{
console
.
log
(
myDiagram
.
model
.
toJson
());
}
}
const
dragStartOffsetX
=
ref
()
const
dragStartOffsetY
=
ref
()
// 获取拖动开始时的偏移量
function
dragstart
(
event
:
any
){
const
target
=
event
.
target
;
...
...
@@ -539,21 +553,16 @@ function drop(event: any) {
// 获取像素比率
const
pixelRatio
=
myDiagram
.
computePixelRatio
();
if
(
!
(
target
instanceof
HTMLCanvasElement
))
return
;
// 获取目标元素的边界框
const
bbox
=
target
.
getBoundingClientRect
();
let
bbw
=
bbox
.
width
;
if
(
bbw
===
0
)
bbw
=
0.001
;
let
bbh
=
bbox
.
height
;
if
(
bbh
===
0
)
bbh
=
0.001
;
// console.log(bbox)
// 计算鼠标在画布上的位置
const
mx
=
event
.
clientX
-
bbox
.
left
*
(
target
.
width
/
pixelRatio
/
bbw
);
const
my
=
event
.
clientY
-
bbox
.
top
*
(
target
.
height
/
pixelRatio
/
bbh
);
const
point
=
myDiagram
.
transformViewToDoc
(
new
go
.
Point
(
mx
-
dragStartOffsetX
.
value
,
my
-
dragStartOffsetY
.
value
));
// console.log(mx)
// console.log(my)
// console.log(point)
// 开始一个新的事务
myDiagram
.
startTransaction
(
'new node'
);
// 获取拖动数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment