Start Webkit-Animation when Page is actually displayed
I stumbled into a problem with CSS-Animations. It seems that they start when the page loads in the background. So the worst case would be, that you have a 3 Second animation on Page 2, but the user reads for more than 3 seconds minutes on the first page. When he swipes to that page 2, the animation is already over.
Is there a way to start animation, when the page is actually displayed?
Thanks! Florian
Does it happen only with CSS animations or also with JavaScript animations? :o
JS-Animations are baaaaaaaad on an iPad because they are not hardware accelerated...
I tried a animation I built with HYPE and -webkit-animation. And in both cases, it started when loading not when displayed. Maybe there is a solution with js (I know that there are some scripts, which trigger when the object is in the viewport)
cheeers and thanks a lot a lot a lot you guys!
Hahaha I know, I was just trying to nail down the problem. Do you have a sample page that you can link for testing? :)
Well, if JS is delayed and CSS not, we might have a simple workaround by triggering a class when the page is displayed, and the class triggers then the CSS animations. But still, that would be a workaround.
For now, I'll mark this as bug. :)
Hey foletto,
not yet, but I'm working on the link... JS-Animations are also NOT delayed...
Ok, thanks. :)
I also found out about this issue after creating some animations in Hype (which runs smoothly by the way!) and thought about a solution for a few days now. No real solutions came up yet ;)
Some solutions:
Solution 1: start your animation (which is on the next page) after X seconds. Remark: doesn't work, because you'll never know how long it takes someone to read the current page.
Solution 2: build 'something' which tells the animation to start when that actual page is loading. Remark: doesn't work, because Baker does a pre-load of the next page and so the animation thinks it needs to start.
'Best' idea so far: loop the animation so it will always be visible from start. But I realize this isn't a solution in some (or many) cases. Works for pages like advertisements.
I can send my files/animation for testing purposes.
Right now we are thinking about adding a couple of JS callbacks, so you'll know when the page is "shown". Problem: that will break compatibility with anything that's not Baker, so we'll see. I'd prefer to avoid it. :)
I am not so fussed, as so far X seconds delay seems to be OK. But I suppose it depend on how sensitive the relation between animation and page load. For the animations themselves, I have found Hype output quite slow, and am having more luck using Firmin.js. Firmin is very light and leverages CSS Transform to get hardware acceleration.
Btw, I found this code, did someone tried it yet? http://code.google.com/chrome/whitepapers/pagevisibility.html
I do have time and I'd like to try this, but my knowledge about JS is very poor. Can I just paste one of the examples between script-tags and then it should work?
Xmas just did a commit this morning, try the current master. ;)
Alright, I'll check it out!
Off-topic: when I'm building my apps I'm making some changes on the original Baker Framework (icons, adding Google Analytics, re-design loading page, portrait/landscape, etc.). With every new master I have to do this over and over, is that right? Just curious, not complaining :)
Well:
- icon and loading image — yes, since they need to be builtin.
- google analytics — I don't know what you are using
- portrait/landscape setting — no, when we are going to release the new spec (book.json), except for the loading screen, yes
Curious to know if the document.webkitHidden state approach was successful in dealing with the original issue. Can experiment if no has as of yet. Thanks!
@eaglejohn if the changes are not massive you should be able to manage them via git. If you fork the Baker repository and regularly rebase/merge your branch over Baker's master, git should take care of applying all your changes automatically.
Btw, is the original issue solved? If so, it'd be nice to update and close the thread ;)
Yeah, I guess the original issue is solved in Baker 3.0 :)