heygrady / transform

jQuery 2d transformation plugin
437 stars 87 forks source link

Don't work on <canvas> and <img> elements #9

Closed MrTomAsh closed 14 years ago

MrTomAsh commented 14 years ago

When try to transform any canvas or img (by Id or Class) - just nothing happen.

heygrady commented 14 years ago

Really? It should work just fine on images. Which browser are you using? What code did you try? Please make it easier for me to help you.

<!-- This will work in FF 3.5+ -->
<img src="http://www.iconarchive.com/icons/visualpharm/animals/256/Elephant-icon.png" style="-moz-transform: rotate(45deg);" />
<script>
    // we can also do this in JavaScript
    $('img').transform({scale: 1.5, skew: [33, 33]});
</script>

http://wiki.github.com/heygrady/transform/

MrTomAsh commented 14 years ago

You're right - it's working. Maybe it's not working for me before because I try to transform element witch is create in JS.

I'm working at my new site and need to transform the reflection of my projects. Unfortunately I don't know Canvas so much to do it on it.

MrTomAsh commented 14 years ago

I make another test - it's work for my in canvas but not on canvas (id/class) creating by JS.

Work: HTML create by JS: < canvas id="reflect[0]">< /canvas>

JS: $('canvas').transform({scale: 1.5, skew: [33, 33]});

Didn't work: HTML create by JS: < canvas id="reflect[0]">< /canvas>

JS: $('#reflect[0]').transform({scale: 1.5, skew: [33, 33]});

Found the solution!

Work on: HTML create by JS: < canvas id="reflect0">< /canvas>

JS: $('#reflect0').transform({scale: 1.5, skew: [33, 33]});

dylanharrington commented 14 years ago

'#reflect[0]' isn't returning any elements but 'canvas' is, so it seems like it's just an issue with your selectors / your ids aren't compatible with jQuery.

for instance, the below code works just fine in my firebug console: jQuery('.perspective canvas').transform({scale: 1.5, skew: [33, 33]}); and jQuery('.whatever').transform({scale: 1.5, skew: [33, 33]}); works if I give one of the canvas elements a class of 'whatever'.

MrTomAsh commented 14 years ago

Thanks! Issue closed.

MrTomAsh commented 14 years ago

If you have a moment - look on my site. Elements transform and animate but sometimes they get a wrong scale. Try few times. And if you wait while (about 3-4 sec) it gets right scale (in debug mode everything going mad for 1s like searching the right number).

Chome 6.0.490.1 dev / MacOS X 10.6.4