@@ -159,22 +159,26 @@ export default {
159
159
},
160
160
methods: {
161
161
addObject () {
162
- if (this .inputs .type === " Image" )
163
- loadImage ({
164
- " pos" : {
165
- " x" : parseInt (this .inputs .x || " 0" ),
166
- " y" : parseInt (this .inputs .y || " 0" ),
167
- " width" : parseInt (this .inputs .width || " 120" ),
168
- " height" : parseInt (this .inputs .height || " 120" ),
169
- },
170
- " draggable" : true ,
171
- " snapToGrid" : this .inputs .snapToGrid ,
172
- " type" : " rect" ,
173
- " src" : this .inputs .url ,
174
- " rotation" : parseInt (this .inputs .rotation || " 0" ),
175
- " color" : this .inputs .color ,
176
- });
177
- else
162
+ if (this .inputs .type === " Image" ) {
163
+ let image = new Image ();
164
+ image .onload = () => {
165
+ loadImage ({
166
+ " pos" : {
167
+ " x" : parseInt (this .inputs .x || " 0" ),
168
+ " y" : parseInt (this .inputs .y || " 0" ),
169
+ " width" : parseInt (this .inputs .width || image .width + " " ),
170
+ " height" : parseInt (this .inputs .height || image .height + " " ),
171
+ },
172
+ " draggable" : true ,
173
+ " snapToGrid" : this .inputs .snapToGrid ,
174
+ " type" : " rect" ,
175
+ " src" : this .inputs .url ,
176
+ " rotation" : parseInt (this .inputs .rotation || " 0" ),
177
+ " color" : this .inputs .color ,
178
+ });
179
+ };
180
+ image .src = this .inputs .url ;
181
+ } else
178
182
loadRect ({
179
183
" pos" : {
180
184
" x" : parseInt (this .inputs .x || " 0" ),
@@ -198,15 +202,3 @@ export default {
198
202
<style scoped lang="scss">
199
203
@import " assets/css/scheme" ;
200
204
</style >
201
- {
202
- "pos": {
203
- "x": object.x(),
204
- "y": object.y(),
205
- "width": object.width() * object.getTransform().getMatrix()[0],
206
- "height": object.height() * object.getTransform().getMatrix()[3]
207
- },
208
- "snapToGrid": object.snapToGrid,
209
- "type": "rect",
210
- "color": object.fill(),
211
- "rotation": object.rotation()
212
- }
0 commit comments