javascript - Moving in an Arc with Webkit Transitions -
right i'm trying put simple, learn it, , incorporate in bigger project.
i have simple box i'm trying move 1 position using css webkit animations , translate function (for ios hardware acceloration purposes). need move in arc , stay @ point @ top of arc.
now, i'm pretty new css transitions. in past i've used jquery animations seems run on mobile devices. know there's best practice ideas can incorporate here setting , manging these animations, i'm kinda figuring them out go.
right box moves way , appears in starting position. how stay there?
http://cs.sandbox.millennialmedia.com/~tkirchner/rich/m/march_madness/tmp/
<style type="text/css"> #ball { display:block; position: absolute; width: 50px; height: 50px; overflow: hidden; top: 500px; left: 100px; background-color: red; } #action { display: block; font-weight:bold; } .animation { -webkit-animation-name: throwball; -webkit-animation-timing-function: linear; -webkit-animation-duration: 1s; -webkit-animation-iteration-count: 1; } @-webkit-keyframes throwball { { -webkit-transform: translate( 0px, 0px ); } 25% { -webkit-transform: translate( 75px, -25px ) } 50% { -webkit-transform: translate( 150px, -75px ) } 75% { -webkit-transform: translate( 225px, -150px ) } { -webkit-transform: translate( 300px, -300px ); } } </style> <script type="text/javascript"> if ( typeof(jquery) == 'undefined' ) document.write('<scri'+ 'pt type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></scri'+'pt>'); </script> <a id='action'>animate me</a> <div id='ball'></div> <script type="text/javascript"> $(document).ready(function(){ $('#action').bind('click',function(){ $('#ball').addclass('animation').bind('webkitanimationend',function(){ }); }); }); </script>
just add end state of animation class properties set animation removed when animation ends. adding -webkit-transform: translate(300px, -300px);
animation
class fixes problem.
.animation { -webkit-animation-name: throwball; -webkit-animation-timing-function: linear; -webkit-animation-duration: 1s; -webkit-animation-iteration-count: 1; -webkit-transform: translate(300px, -300px); }
Comments
Post a Comment