PaintWeb imageLoad is not loading=>quick fix

29 views
Skip to first unread message

nvd_ai

unread,
Jul 27, 2011, 4:14:00 AM7/27/11
to PaintWeb discussions
PaintWeb.imageLoad does not load the image.
If I am right issue #39 refers to this problem:

Issue 39: PaintWeb fails to load without config.imageLoad
----------------------------------------
Not working:
var newImg = document.createElement("img");
newImg.src = myImg.src;
pw.imageLoad(newImg);//pw is initialized instance of paintweb


Quick fix://works all the time as far as I tested
var newImg = document.createElement("img");
newImg.src = myImg.src;
var self=this;
setTimeout(function(){
self.pw.imageLoad(newImg);
}, 200);


It seems that paintweb can not access the src of image right after it
has been set. But if I give it a bit of time, it will manage to load
it. I chose 200 randomly. It probably works with much shorter time as
well, due to the context change caused by setTimeout.


However, I am running into a new problem. After the new image has been
set, the Stroke and Fill color is reset to black! and the color shown
for Stroke and Fill on the top right of PaintWeb remains as it was
before. Whatever user draws from now will be in black! It seems like
paintweb resets current style and does not load it back, and does not
update the UI according to reseted style. Is there any quick fix to
this?



Reply all
Reply to author
Forward
0 new messages