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

translation not working properly in IE8 #31

Open
abhayastudios opened this issue Nov 24, 2011 · 2 comments
Open

translation not working properly in IE8 #31

abhayastudios opened this issue Nov 24, 2011 · 2 comments

Comments

@abhayastudios
Copy link

Hi,

I am using your JQuery 2D transform plugin to rotate images as follows:

$("#crop_container img").transform(
{
translateX: translateX+'px',
translateY: translateY+'px',
rotate: rotation+'deg'
});

Where the crop_container is an absolutely positioned div wrapped around the image as you suggested in another issue. The translation is calculated on basis of the image orientation (portrait/landscape) and its rotation. For landscape and 90 or 270 degrees it is:

translate=(imagewidth-imageheight)/2;
translateX = '-'+translate;
translateY = translate;

All is good in FF/Webkit/IE9, but in IE8 it seems the translation is off. I read in a wiki page that "IE also lacks support for transform-origin and translate() [...] The jQuery Transform plug-in handles these calculations automatically". If this is true then I must be doing something wrong or there is a bug.

Any ideas/advice?

Thanks!

@brendanmckeown
Copy link

I'm also having trouble with this same issue. In IE 8, when a rotated object is translated, it moves along it's own axis, not straight up/down/left/right, so you can get some funky results. Every other browser including IE 9 performs this transformation correctly. See this example: http://jsfiddle.net/kzMff/9/

Does anyone have a solution to this?

@brendanmckeown
Copy link

I found a fix for this issue, at least for my usage. In the execMatrix function, replace this line (around 290):

this.fixPosition(matrix, tx, ty);

with this:

// factor in the object's current rotation so translation remains straight up/down/left/right
// otherwise, object will be translated along the rotated axis, which produces undesirable effects
var rotation = parseInt(this.$elem.css('rotate')) * -1, // the current rotation in degrees, inverted
radians = rotation * (Math.PI / 180), // convert degrees to radians
newX = (tx * (Math.cos(radians))) - (ty * (Math.sin(radians))), // calculate new x
newY = (tx * (Math.sin(radians))) + (ty * (Math.cos(radians))); // calculate new y

this.fixPosition(matrix, newX, newY);

Hope this helps.

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

No branches or pull requests

2 participants