Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c8aa46a5
authored
Jun 11, 2023
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fabric v4至v5事件兼容升级及优化
1 parent
d7f71b0a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
vue3-lw-pc/src/views/contentCenter/components/PosterAdd.vue
vue3-lw-pc/src/views/contentCenter/components/PosterAdd.vue
View file @
c8aa46a
...
@@ -521,7 +521,7 @@ export default {
...
@@ -521,7 +521,7 @@ export default {
}
}
this
.
setPosterBackgroundImage
()
this
.
setPosterBackgroundImage
()
// 删除
某个图层
// 删除
图层按钮
let
deleteBtn
=
document
.
getElementById
(
'deleteBtn'
)
let
deleteBtn
=
document
.
getElementById
(
'deleteBtn'
)
function
addDeleteBtn
(
x
,
y
)
{
function
addDeleteBtn
(
x
,
y
)
{
...
@@ -532,10 +532,15 @@ export default {
...
@@ -532,10 +532,15 @@ export default {
}
}
canvas
.
on
(
'selection:created'
,
function
(
e
)
{
canvas
.
on
(
'selection:created'
,
function
(
e
)
{
addDeleteBtn
(
e
.
target
.
lineCoords
.
tr
.
x
,
e
.
target
.
lineCoords
.
tr
.
y
)
addDeleteBtn
(
e
.
selected
[
0
].
lineCoords
.
tr
.
x
,
e
.
selected
[
0
]
.
lineCoords
.
tr
.
y
)
})
})
canvas
.
on
(
'selection:updated'
,
function
(
e
)
{
canvas
.
on
(
'selection:updated'
,
function
(
e
)
{
addDeleteBtn
(
e
.
target
.
lineCoords
.
tr
.
x
,
e
.
target
.
lineCoords
.
tr
.
y
)
let
activeObject
=
canvas
.
getActiveObject
()
if
(
activeObject
.
_objects
?.
length
>
1
)
{
deleteBtn
.
style
.
display
=
'none'
}
else
{
addDeleteBtn
(
e
.
selected
[
0
].
lineCoords
.
tr
.
x
,
e
.
selected
[
0
].
lineCoords
.
tr
.
y
)
}
})
})
//通用事件另外写法
//通用事件另外写法
...
@@ -620,21 +625,20 @@ export default {
...
@@ -620,21 +625,20 @@ export default {
})
})
// alt键缩放
// alt键缩放
document
.
getElementById
(
'canvas-wrap'
).
addEventListener
(
'wheel'
,
(
e
)
=>
{
//
document.getElementById('canvas-wrap').addEventListener('wheel', (e) => {
// e.stopPropagation()
//
// e.stopPropagation()
if
(
e
.
altKey
)
{
//
if (e.altKey) {
e
.
preventDefault
()
//
e.preventDefault()
console
.
log
(
e
)
//
console.log(e)
let
zoom
=
(
e
.
deltaY
>
0
?
0.1
:
-
0.1
)
+
canvas
.
getZoom
()
//
let zoom = (e.deltaY > 0 ? 0.1 : -0.1) + canvas.getZoom()
zoom
=
Math
.
max
(
0.1
,
zoom
)
//最小为原来的1/10
//
zoom = Math.max(0.1, zoom) //最小为原来的1/10
zoom
=
Math
.
min
(
5
,
zoom
)
//最大是原来的5倍
//
zoom = Math.min(5, zoom) //最大是原来的5倍
let
zoomPoint
=
new
fabric
.
Point
(
e
.
offsetX
,
e
.
offsetY
)
//
let zoomPoint = new fabric.Point(e.offsetX, e.offsetY)
canvas
.
zoomToPoint
(
zoomPoint
,
zoom
)
//
canvas.zoomToPoint(zoomPoint, zoom)
}
//
}
})
//
})
deleteBtn
.
addEventListener
(
'click'
,
()
=>
{
deleteBtn
.
addEventListener
(
'click'
,
()
=>
{
let
activeObject
=
canvas
.
getActiveObject
()
if
(
activeObject
)
{
if
(
activeObject
)
{
this
.
$confirm
(
'是否确认删除吗?'
,
'警告'
,
{
this
.
$confirm
(
'是否确认删除吗?'
,
'警告'
,
{
confirmButtonText
:
'确定'
,
confirmButtonText
:
'确定'
,
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment