Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
4a39b2b6
Commit
4a39b2b6
authored
Jan 11, 2018
by
bbaer
Browse files
fixed error with resizing and empty fabric json not displaying an image
parent
10629efb
Changes
1
Hide whitespace changes
Inline
Side-by-side
javascript/src/Plugins/qfq.fabric.js
View file @
4a39b2b6
...
...
@@ -327,14 +327,15 @@ $(function (n) {
console
.
log
(
"
prepareStaticCanvas
"
);
this
.
generateStaticCanvas
(
width
,
height
);
if
(
this
.
fabricJSON
)
{
console
.
log
(
"
getFabric
"
);
this
.
canvas
.
loadFromJSON
(
this
.
fabricJSON
);
}
else
{
this
.
setBackground
();
}
this
.
resizeCanvas
();
this
.
canvas
.
renderAll
();
var
that
=
this
;
setTimeout
(
function
()
{
that
.
resizeCanvas
();
that
.
canvas
.
renderAll
();
},
1000
);
};
...
...
@@ -348,6 +349,7 @@ $(function (n) {
this
.
parentElement
.
append
(
canvas
);
this
.
canvas
=
this
.
__canvas
=
new
fabric
.
StaticCanvas
(
canvas
);
this
.
parentElement
.
on
(
"
click
"
,
function
(
e
)
{
that
.
toggleObjects
();
});
$
(
window
).
resize
(
function
()
{
that
.
resizeCanvas
();
});
};
n
.
Fabric
.
prototype
.
getMeta
=
function
(
url
,
callback
)
{
...
...
@@ -431,11 +433,17 @@ $(function (n) {
n
.
Fabric
.
prototype
.
resizeCanvas
=
function
()
{
console
.
log
(
"
resize canvas started
"
);
var
source
=
false
;
var
backgroundSizing
=
false
;
var
oldWidth
=
this
.
canvas
.
getWidth
();
var
backgroundImageWidth
=
0
;
if
(
this
.
canvas
.
backgroundImage
)
{
backgroundImageWidth
=
this
.
canvas
.
backgroundImage
.
width
||
0
;
source
=
this
.
canvas
;
}
else
{
source
=
this
.
fabricJSON
;
}
if
(
source
)
{
backgroundImageWidth
=
source
.
backgroundImage
.
width
;
}
if
(
oldWidth
!==
backgroundImageWidth
&&
backgroundImageWidth
!==
0
)
{
oldWidth
=
backgroundImageWidth
;
...
...
@@ -446,13 +454,17 @@ $(function (n) {
var
scaleMultiplier
=
newWidth
/
oldWidth
;
var
oldHeight
;
if
(
backgroundSizing
)
{
oldHeight
=
this
.
canvas
.
backgroundImage
.
height
||
0
;
if
(
source
)
{
oldHeight
=
source
.
backgroundImage
.
height
;
}
}
else
{
oldHeight
=
this
.
canvas
.
getHeight
();
}
this
.
canvas
.
setWidth
(
this
.
parentElement
.
inner
Width
()
);
this
.
canvas
.
setWidth
(
new
Width
);
this
.
canvas
.
setHeight
(
oldHeight
*
scaleMultiplier
);
var
objects
=
this
.
canvas
.
getObjects
();
var
objects
=
source
.
getObjects
();
for
(
var
i
in
objects
)
{
objects
[
i
].
scaleX
=
objects
[
i
].
scaleX
*
scaleMultiplier
;
objects
[
i
].
scaleY
=
objects
[
i
].
scaleY
*
scaleMultiplier
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment