CSS transition or animation not working in phonegap
Asked Answered
R

2

5

I need to animate a <div>. Tried using @keyframes and transition. Here's a code:

TRANSITION

#menu{
...
width:70%;
-webkit-transition: width 5s;
..
}

KEYFRAMES

#menu{
    ...
    width:70%;
    animation: menuEffect 3s;
    ..
    }
@keyframes menuEffect
{
from {width:0%;}
to {width:70%;}
}

I'm using cordova/phonegap 2.0.0 and targeting android 4.0 and above. I do not see this working. Does transition and animation not support phonegap? Please assist.

Rajkot answered 19/4, 2013 at 18:28 Comment(1)
have you tried transition: width 5s;?Finished
S
12

Just don't forget to prepend -webkit- to the css properties. It fixed all the problems for me.

This code worked in my case:

/* Animation element id */
#animate {
  position: absolute;
  top: 100px;
  left: 100px;
  -webkit-animation: move 1s ease infinite;
}

@-webkit-keyframes move {
    50% {
        -webkit-transform: translate(100px, 100px);
    }
}

You can also use 'from, to' and it would just work fine.

Speight answered 29/9, 2014 at 16:19 Comment(0)
P
6

With Phonegap you need to use the prefixed versions of the properties because it's just Webkit.

-webkit-animation: menuEffect 3s linear

@-webkit-keyframes menuEffect
{
    from {
        width:0%;
    }
    to {
        width:70%;
    }
}
Purulence answered 2/7, 2013 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.