I'm creating an HTML5 app for iPhone to run in a UIWebview using Sencha Touch 2.
I've created several methods to help myself to css animations. One of them does translate in the Y axis for me. I've set on things like -webkit-backface-visibility in my CSS to help smooth over animations. I've tried webkit perspective and webkit preserve-3d, but they seem to not help.
Anyways, I've gotten the animations to a point where they are very smooth. The problem is, if I'm translating a large group of elements simultaneously, one of them won't translate.
Let's say I'm translating A, B, C, D, E, and F upwards. F will just skip right to the end -- no translation. It's almost as if the -webkit-transform gets set before the -webkit-transition-duration, which is not what's happening in my code. Furthermore, A, B, C, D, and E animation perfectly.
I'm not even sure if this is exclusive to when I'm animating a large group of elements, but that seems to be how it is happening now. If it happens to F, it will always happen to F -- so it is at least consistent in that sense.
I even tried to fix it by dynamically creating a element with a new class style equal to the transform and duration, embedding that in the DOM, and then setting the element's class equal to the class of the style. I got the same problem.
The thing is, if I embed the final line of Animations.translateY in a setTimeout function, even for 1 millisecond delay, the everything will always animate. This, however, leads to the screen flickering nastily ~33% of the time, which I'm guessing is due to too many setTimeouts?
As for browser consistency, I see the lack of animation (without setTimeout) in both chrome on my PC and the UIWebview on the iPhone device. I only see flicker (with setTimeout) on the iPhone device.
Animations.translateY = function(element, measurement, duration, callback, easing)
{
Animations.setAnimationCallback(element,callback)
var css = "translate3d(0,"+measurement+",0)";
duration = parseFloat(duration);
element.style['-webkit-transition-duration'] = duration + 's';
element.style['-webkit-transform'] = css
}
the animation callback code.. I feel this is irrelevant, because the callback never actually fires (animations that take 0s don't fire a callback)
Animations.setAnimationCallback = function(element, callback)
{
//set callback handler
element.addEventListener('webkitTransitionEnd',
function(){
//set animation duration back to 0
this.style['-webkit-transition-duration'] = "0s";
if(callback != null)
{
callback();
}
this.removeEventListener('webkitTransitionEnd', arguments.callee, null);
});
}