caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

Calling setLayer on a newly created text layer leaves text being undefined #163

Closed nickw444 closed 10 years ago

nickw444 commented 10 years ago

When checking the object before setLayer is called, the property text is set to underfined, although there is text rendered on the screen for this layer.

When setLayer is called, the text is then updated on the canvas to underfined as per the property.

Browser: Chrome Version 36.0.1985.143 OS: OSX Mavericks

nickw444 commented 10 years ago

Workaround:

var layer = $('canvas').getLayer('my_layer');
var text = layer.text;

$('canvas').setLayer('my_layer', {
   x: 100,
   y: 100,
   text: text,
});
$('canvas').drawLayers();
caleb531 commented 10 years ago

Thanks for the report. However, I am unable to reproduce the issue. Could you please provide a complete (ideally simplified) code sample that reproduces the bug?

Thanks, Caleb

nickw444 commented 10 years ago

Unable reproduce, will re-open if this shows up again.

Nierrrrrrr commented 10 years ago

Hi, I have a similar problem here. When I use setLayer to set a text's visible from false to true, it will let the text be "undefined". I use mouseover to set that text's visible to false and use mouseout to set it to true. After the mouse moving in and out, the text became "undefined".

caleb531 commented 10 years ago

Again, I am asking for a valid code sample that reproduces the issue before I can investigate the issue further.

-Caleb

Nierrrrrrr commented 10 years ago

Hello, I'm sorry that I didn't provide the code sample. When I trying to reproduces the issue, I found that I works fine in Sandbox of jCanvas website. However, the issue is still there in my personal website. The website code is here: http://codepad.org/hdkVopF9 and the result is like: http://i.imgur.com/rvZ2iDz.png

caleb531 commented 10 years ago

What version of jCanvas are you using?

-Caleb

On Sep 26, 2014, at 7:37 PM, Nierrrrrrr notifications@github.com wrote:

Hello, I'm sorry that I didn't provide the code sample. When I trying to reproduces the issue, I found that I works fine in Sandbox of jCanvas website. However, the issue is still there in my personal website. The website code is here: http://codepad.org/hdkVopF9 and the result is like: http://i.imgur.com/rvZ2iDz.png

— Reply to this email directly or view it on GitHub.

Nierrrrrrr commented 10 years ago

/ jCanvas v14.09.14 Copyright 2014 Caleb Evans Released under the MIT license / I just download it 2 days ago.

I make a live demo here: http://jsfiddle.net/jrttgguL/

And I found that if I using @license jCanvas v14.07.16, no "undefined" issue. It works fine at previous version, which sandbox uses. Demo here: http://jsfiddle.net/n5ee0x2d/

caleb531 commented 10 years ago

Thank you, Nierrrrrrr, for reaching out to me regarding this issue—I have confirmed that this is a jCanvas bug. Fortunately, the fix is extremely simple, and the patched build is now available on master as v14.09.27.

Thanks again, Caleb

caleb531 commented 10 years ago

Okay, after throwing your codepad code into an HTML file and viewing that, I can confirm that this is a jCanvas bug. Good news is, fixing the bug turned out to be extremely simple.

I've just pushed the patched build to GitHub as v14.09.27.

-Caleb

On Sep 27, 2014, at 6:12 AM, Nierrrrrrr notifications@github.com wrote:

/ jCanvas v14.09.14 Copyright 2014 Caleb Evans Released under the MIT license / I just download it 2 days ago.

— Reply to this email directly or view it on GitHub.

nickw444 commented 10 years ago

+1 Thanks Caleb