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

No background colour after loadFromJSON when image present. #3028

Closed
otarsko opened this issue Jun 4, 2016 · 6 comments · Fixed by #3029
Closed

No background colour after loadFromJSON when image present. #3028

otarsko opened this issue Jun 4, 2016 · 6 comments · Fixed by #3029
Labels

Comments

@otarsko
Copy link

otarsko commented Jun 4, 2016

Version

1.6.2

Test Case

https://jsfiddle.net/oxz3r51u/6/

Steps to reproduce

  1. Serialize canvas with background colour set and with image
  2. Try to load canvas from JSON above
  3. Image is there but no background colour

Expected Behavior

Background colour should be restored from JSON.

Actual Behavior

No background colour set.

Note

  1. After downgrade to 1.6.0 - bug could not be reproduced (1.6.1 not tested)
  2. There is similar ticket - node fabric 1.6.1 background shows, but 1.6.2 it does not #3024 but it's poorly formatted.
@asturur
Copy link
Member

asturur commented Jun 4, 2016

if you switch the property from background to backgroundColor it goes. Guess what happened... i'm gonna look at it.

@otarsko
Copy link
Author

otarsko commented Jun 4, 2016

Yes, I see. Also I am using setBackgroundColor method to set background colour.
Also as wrote, it fails only if there is image on canvas.

@butch2k
Copy link

butch2k commented Jun 4, 2016

Actually the problem is even more acute in 1.6.3 (did not test on 1.6.2) as if you set a background image it is not enlivened if images are present in the JSON.

@butch2k
Copy link

butch2k commented Jun 4, 2016

Ok found out where the issue comes form:

in loadFromJSON
delete serialized.objects; delete serialized.backgroundImage; delete serialized.overlayImage; delete serialized.background; delete serialized.overlay;
Comment out the delete serialized.background; and it should fix your issue, mine is related if i comment out delete serialized.backgroundImage; i get my images AND the background.

@butch2k
Copy link

butch2k commented Jun 4, 2016

I believe data is being deleted before this._enlivenObjects() has finished it's job. Better to call the deletes in _this._setBgOverlay's callback i believe.
Async loading is sometimes a real pain.

@asturur asturur added the bug label Jun 5, 2016
@asturur
Copy link
Member

asturur commented Jun 5, 2016

it is a recent regression and butch2k is right. i have to delete data in the callback and restore properties.

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

Successfully merging a pull request may close this issue.

3 participants