MobiGeni - iPhone Development - iPad Development
Mobile Application Development
  • Home
  • Portfolio
  • Services
    • iPhone Software Development
    • iPad Software Development
    • Web Development
    • User Interface Design
  • About
    • About Us
    • Team
  • Blog
    • News
    • iPad
    • iPhone
    • Goodies
    • Code
    • Technology
    • Design
  • Contact
Select Page ...

How to use hardware accelerated CSS3 3D Transitions on iPad and iPhone

1 Comment By: admin Published: September 22, 2010
Posted in: Blog Tags: 3d, CSS3, Hardware, hardware accelerated, Native 3d, translate3d

CSS3 3D Transforms

CSS3 transforms allow the rendering of an HTML element to be modified using 2D and 3D transformations such as rotation, scaling, and translations. Transforms are applied by setting the -webkit-transform CSS property with the desired list of transforms. Each transform takes the form of a transformation function, such as translate3d
or rotate, and a list of parameters enclosed in brackets. For example, to move an object to the right by 100 pixels and rotate it by 45 degrees you can use the 

-webkit-transform

property:

-webkit-transform: translate(100px, 0) rotate(45deg);

Use translate3d, not translate

When using -webkit-transform, be sure to use the 

translate3d(x,y,z)

syntax, instead of using translate(x,y). For some reason, the latter is not hard-accelerated, at least not on iPhone OS 3.x (it seems to work fine on desktop Safari, tho).

Using -webkit-transform as the transition property when moving an element is advantageous relative to using the standard top and left properties because transitions using -webkit-transform are hardware-accelerated in Safari. An exception here is that it seems that 2D translations are not hardware-accelerated. But, since any 2D translation is equivalent to a corresponding 3D translation with the same translations in the x and y and no translation in the z axis, it is easy to use a hardware accelerated translate3d(x, y, 0) transform instead of a non-hardware accelerated translate(x, y) transform.

Terminology

There are a few terms here that begin with ‘trans,’ and they can easily be confused if you are not familiar with them. Here they are again:

  • Transition: An implicit animation of CSS properties between an initial and a final value.
  • Transform: A modification to the appearance of an HTML element by manipulating it in a 2D or 3D space.
  • Translation: A particular type of transformation that moves the HTML element in 2D or 3D space.

Source: Google Code

← Apple accepts third-party private frameworks for iOS development
jQuery Mobile Touch framework for Mobile devices & Tablets →
admin

One Response to How to use hardware accelerated CSS3 3D Transitions on iPad and iPhone

  • Rainer Schleevoigt
    1 / 28 / 2011

    Hi,

    To rotate a marker in google maps I tried

    $(‘img[src="./static/map/Kompass_1.png"]‘).parent().css({
    ‘-webkit-transform’:'rotate(‘ + ni + ‘deg)’,
    ‘-moz-transform’:'rotate(‘ + ni + ‘deg)’
    });

    It works fine in safari, but not in mobile safari.

    Any ideas?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Categories

    • Blog
    • Code
    • Design
    • Goodies
    • iPad
    • iPhone
    • News
    • Technology
    • Connect & Share

      Follow Us on FacebookFollow Us on GoogleFollow Us on LinkedInFollow Us on Twitter
      • Recent Tweets

        Follow @mobigeni

      • Front-end Developer.com
      • ScriptGeni Web Development
      • CSS Playground
      Copyright © 2012 MobiGeni.com. All Rights Reserved