SharkGamesYT / jquery-rotate

Automatically exported from code.google.com/p/jquery-rotate
0 stars 0 forks source link

error with firefox #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, 
sorry for my english...

What steps will reproduce the problem?
I load many image with tag <img> each included in <div>. When i rotate
<img> firefox return this exception (after first image loaded): 

[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
/jquery/jquery.rotate.1-1.js :: anonymous :: line 51" data: no]
[Break on this error] 

LINE 51:
context.drawImage(canvas.oImage, 0, 0, canvas.oImage.width,
canvas.oImage.height);

When i reload the page 3 image are show, the next reload 5 image, the next
reload 8 image, ... and finaly all image are show.

What version of the product are you using? On what operating system?
I have this problem with firefox (2.0.0.13 and 3.0b5), no with IE. 

Please provide any additional information below.

Original issue reported on code.google.com by a.sterp...@gmail.com on 8 Apr 2008 at 9:52

GoogleCodeExporter commented 9 years ago
This is indeed a bug with jquery rotate and firefox, I suggest the dev changes 
the
script to what I suggest below.

The problem is that, in firefox only, if the image hasn't been cached, it 
doesn't
seem to rotate the images, AT ALL! No matter if you add a delay, or even do it 
using
a function in the "onload" attribute of the image.

After many hours, I came up with a solution.

At the moment line 30 onwards looks like this:

canvas.oImage = new Image();
canvas.oImage.src = p.src;

etc.

Add two lines inbetween this two looking like this:

canvas.oImage.onload = function() {
}

Then move the code from:

canvas.style.width = canvas.width = Math.abs(costheta*canvas.oImage.width) +
Math.abs(sintheta*canvas.oImage.height);

to:

context.restore();

into this function. This ensures images are properly loaded. I imagine this is 
a bug
with firefox / canvas. I was preloading the image before running the rotation, 
but
the canvas seems to ignore that. I'd consider this a pretty major problem. 
Anyone
visiting my site on firefox for the first time would not see any rotated images 
and
because of the error a lot of other JS didn't work.

I've attached the updated jquery rotate too. Enjoy!

Original comment by youngest...@gmail.com on 2 Jul 2009 at 3:16

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

I tried your jquery.rotate.js and the first rotation is working fine. But when I
rotate the canvas image, the canvas is empty, and the image is gone away.

any ideas why?

Original comment by s.kimme...@metropolis-ag.de on 30 Nov 2009 at 9:01

GoogleCodeExporter commented 9 years ago
Hi,

Your solution made the trick for me. I have 12 images rotated on the load of 
the page.

If only one image ratated you should check your javascript errors.

Thanks,

Original comment by cybermatthieu on 30 Nov 2009 at 8:44

GoogleCodeExporter commented 9 years ago
See issue 11 which solves the multiple rotation issue as well

Original comment by mike.mik...@gmail.com on 15 Jan 2010 at 12:27