Javascript: Force reflow doesn't work

298 views Asked by At

I made a game where you can walk on a 2d grid world (Pokémon style) and currently you just hop from tile to tile instead of a nice walking animation in between. I'm right now working on that walking animation, and it all works, except that the browser doesn't reflow/repaints fast enough.

If I closely zoom in on the sprite I can see the sprite moving and doing only half of the replaces he needs to do. This creates a lag feeling, which I obviously not want. So I googled today and learned about reflow and repaints and that the browsers stacks the animations until a certain time and then executes them in batches.

I want to avoid the stacking of animations so I searched on Google, and found a lot of hacks, which are not working for me, unfortunately...

I used hacks like requesting the offsetTop, hiding and showing the element, and some others which are easily to be found online. None of them worked.

I then learned here: http://dev.opera.com/articles/view/efficient-javascript/?page=3#reflow that the browser may reflow in the background, without making it visible. (probably why the hacks weren't working)

Do you have any way so I can make the browser visibly reflow?

0

There are 0 answers