baker icon indicating copy to clipboard operation
baker copied to clipboard

Start Webkit-Animation when Page is actually displayed

Open ffranke opened this issue 15 years ago • 16 comments

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

ffranke avatar Aug 17 '11 16:08 ffranke

Does it happen only with CSS animations or also with JavaScript animations? :o

folletto avatar Aug 17 '11 16:08 folletto

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!

ffranke avatar Aug 17 '11 17:08 ffranke

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. :)

folletto avatar Aug 17 '11 17:08 folletto

Hey foletto,

not yet, but I'm working on the link... JS-Animations are also NOT delayed...

ffranke avatar Aug 18 '11 08:08 ffranke

Ok, thanks. :)

folletto avatar Aug 18 '11 08:08 folletto

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.

danielbenjamins avatar Aug 18 '11 09:08 danielbenjamins

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. :)

folletto avatar Aug 18 '11 09:08 folletto

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.

psmedia avatar Aug 26 '11 04:08 psmedia

Btw, I found this code, did someone tried it yet? http://code.google.com/chrome/whitepapers/pagevisibility.html

folletto avatar Aug 26 '11 09:08 folletto

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?

danielbenjamins avatar Aug 31 '11 13:08 danielbenjamins

Xmas just did a commit this morning, try the current master. ;)

folletto avatar Aug 31 '11 13:08 folletto

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 :)

danielbenjamins avatar Aug 31 '11 15:08 danielbenjamins

Well:

  1. icon and loading image — yes, since they need to be builtin.
  2. google analytics — I don't know what you are using
  3. portrait/landscape setting — no, when we are going to release the new spec (book.json), except for the loading screen, yes

folletto avatar Aug 31 '11 17:08 folletto

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!

inventionarts avatar Oct 17 '11 14:10 inventionarts

@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 ;)

Simbul avatar Oct 31 '11 23:10 Simbul

Yeah, I guess the original issue is solved in Baker 3.0 :)

danielbenjamins avatar Nov 01 '11 09:11 danielbenjamins