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

Alter box_3dtransforms to correctly apply perspective property #118

Merged

Conversation

raphaelvalerio
Copy link
Collaborator

The 3dtransforms styles don't apply perspective properly for me right now at the site. According to the spec, the perspective property needs to be applied to the parent container of the element with the transforms, not the element itself. Right now at the site, the .box_3dtransforms styles apply the perspective property to <div id="sandbox">, not its parent container, so perspective doesn't work (the rotated box is squished, without any 3d perspective). That's my experience with Chrome 25, Firefox 19, and IE 10 (Opera of course doesn't support 3d transforms), so they all seem to be implementing the spec as written.

So I have added some code to javascript.js which creates an additional <style> node just with the perspective properties, and then toggles on a class called box_3dtransforms_perspective for <div id="sandboxwrap">. This correctly applies the property styles to the parent container, and now the perspective appears correctly when you toggle on .box_3dtransforms for the sandbox div.

Here's the way box_3dtransforms looks on the current site with rotate set to 45 (without my code, but with a rule added in Chrome Dev Tools and switched off for clarification):

css3please-3dtransforms-01

And here it is at 45 degrees with my code added:

css3please-3dtransforms-02

I wanted to muck around with the code as little as possible, so I limited the changes to be all in one place. This might be a little more inelegant, but it means I'm only changing one JS function. I leave all the box_3dtransforms styles that are applied to the sandbox div (including the perspective styles). The code adds a <style> node and a class to <div id="sandboxwrap">, which just happens to be conveniently sitting there as sandbox's parent container, waiting to help out.

I've tested this on Chrome 25 and Firefox 19.

Please consider pulling in these changes as the site cannot help users who want to see proper perspective on 3d transforms as it stands now.

paulirish added a commit that referenced this pull request Apr 15, 2014
…ctive

Alter box_3dtransforms to correctly apply perspective property
@paulirish paulirish merged commit 4901ec9 into paulirish:master Apr 15, 2014
@paulirish
Copy link
Owner

merged!

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

Successfully merging this pull request may close these issues.

None yet

2 participants