Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group.prototype.toObject() does not clone objects in objects array correctly #260

Closed
jefflembeck opened this issue Sep 10, 2012 · 11 comments
Labels

Comments

@jefflembeck
Copy link

What I was attempting:

var group = canvas.getActiveGroup();

group.toDataURL();

This returns this error:

TypeError: Cannot read property 'type' of undefined

After doing some inspection, this seems to happen during a .toObject() transfer of the group.

This can be seen here:

https://gist.github.com/57116620ec75efc10fb9

@kangax
Copy link
Member

kangax commented Sep 10, 2012

Groups are async (like images) so you need a callback:

canvas.getActiveGroup().toDataURL(function(data) {
  window.open(data);
});

@kangax kangax closed this as completed Sep 10, 2012
@jefflembeck
Copy link
Author

Still getting the same error in this case:

group.toDataURL(function(data){
  window.open(data);
});

TypeError: Cannot read property 'type' of undefined

For any level of reference, both of the objects are Images.

@kangax
Copy link
Member

kangax commented Sep 10, 2012

Which fabric version?

@jefflembeck
Copy link
Author

Just pulled and built the latest.

@kangax
Copy link
Member

kangax commented Sep 10, 2012

Strange. Which browser?

I just check with 0.9.6 in kitchensink's console —
http://fabricjs.com/kitchensink/ and it works.

On Mon, Sep 10, 2012 at 7:25 PM, Jeff Lembeck notifications@github.comwrote:

Just pulled and built the latest.


Reply to this email directly or view it on GitHubhttps://github.com//issues/260#issuecomment-8442067.

@jefflembeck
Copy link
Author

Chrome 21.0.1180.89, Mac OSX

I'm getting the same error on kitchen sink.

canvas.getActiveGroup().toDataURL(function(data){
console.log(data);
});
TypeError: Cannot read property 'type' of undefined

@kangax
Copy link
Member

kangax commented Sep 10, 2012

And you have an active group selected?

@jefflembeck
Copy link
Author

Nevermind. Did not work in Firefox. Doesn't work when I use images, only when I use basic shapes.

@jefflembeck
Copy link
Author

Yes, in that Chrome window:

canvas.getActiveGroup();
klass
eventListeners: Object
_angle: 0.606961778863658
_hypotenuse: 266.4413254722304
_originalLeft: 439.1144609216958
_originalTop: 380
active: true
currentHeight: 303.9427011655373
currentWidth: 437.7016724731503
height: 303.9427011655373
isMoving: false
left: 439.1144609216958
oCoords: Object
objects: Array[2]
opacity: 1
originalState: Object
top: 380
width: 437.7016724731503
__proto
: subclass

@Kienz
Copy link
Collaborator

Kienz commented Sep 11, 2012

Same error. It seems there is no callback function in the clone function of images:
this.constructor.fromObject(this.toObject(), callback);
In my case callback is undefined => i added two images to canvas and selected them both.

@kangax
Copy link
Member

kangax commented Sep 11, 2012

Yep. Reproduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants