rstacruz / jquery.transit

Super-smooth CSS3 transformations and transitions for jQuery
http://ricostacruz.com/jquery.transit
7.29k stars 863 forks source link

-webkit-perspective on Safari 5.0.5 #115

Open scien opened 11 years ago

scien commented 11 years ago

All rotations, scaling, and transforms break in Safari 5.0.5 when applying perspective.

Example on http://ricostacruz.com/jquery.transit/

$('.header h1').css({scale: .5}) // works $('.header h1').css({scale: 1}) // works $('.header h1').css({perspective: 200}) // sets -webkit-perspective to 200px $('.header h1').css({scale: .5}) // doesn't work

a quick change in the source... this.perspective = dist;//unit(dist, 'px');

and now everything works as expected.

I tried the perspective without "px" and it worked on Safari 5.0.5 and 6.0.2, and Chrome 25. So it seems that all up-to-date browsers support perspective just being an number. According to w3schools, it seems like that was the intention - http://www.w3schools.com/cssref/css3_pr_perspective.asp

I've updated my source with the change, but it'd be good to have some more people test before changing on master.

scien commented 11 years ago

Firefox requires 'px' or 'em' as they use in their documentation https://developer.mozilla.org/en-US/docs/CSS/perspective

scien commented 11 years ago

looks like a similar check to checkTransform3dSupport() will be a reliable test.

firefox

>>> div = document.createElement('div')
<div>
>>> div.style.perspective = 200
200
>>> div.style.perspective
""
>>> div.style.perspective == ''
true

chrome

div = document.createElement('div')
<div>​</div>​
div.style.perspective = 200
200
div.style.perspective
200
div.style.perspective == ''
false