W3C home > Mailing lists > Public > www-style@w3.org > June 2013

Re: [css-display]? Compositing, expensive things, and laziness

From: François REMY <francois.remy.dev@outlook.com>
Date: Fri, 21 Jun 2013 21:19:42 +0200
Message-ID: <DUB120-DS93A40765CD690561007BBA58F0@phx.gbl>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "Ali Juma" <ajuma@chromium.org>, "Robert O'Callahan" <robert@ocallahan.org>, "www-style list" <www-style@w3.org>
> Again, read earlier in the thread.  This exact question was raised by
> roc, and Ali answered him. I'm not as well qualified to answer this.

I don't think our proposal have much in common, except the fact both use 
rAF. Roc's proposal was about using the normal rAF to trigger the animation 
in a delayed fashion (which does not work because you just delayed the 
problem). That's not what I'm proposing.

Maybe I didn't express my idea well, but I propose to use

    (1) the "display-optionality: optional" declaration to indicate the 
rendering of the element is facultative.
    (2) an element-tied rAF which only fires when an element has been 
painted and is ready for his next frame.

So, let's imagine we have our javascript that decide the video is preloaded 
:

    {
        theVideo.classList.add("start-rendering");
        theVideo.requestAnimationFrame(function() {
            // theVideo has been drawn during previous frame:
            // we're ready to start fading in
            theVideo.classList.add("start-fading-in");
        });
    }

In the case the "start-rendering" operation succeed at the first frame, the 
video starts fading in immediately; otherwhise a few "global AF" may elapse 
before our first theVideo's AF is called.



Another way to express it, this time with pseudo-code:

    theVideo.requestAnimation(callback) :=
        window.requestAnimationFrame(=> {
            if(theVideo._wasNotRenderedInPreviousFrame) { 
window.requestAnimationFrame(arguments.callee); }
            else { callback(); }
        }) 
Received on Friday, 21 June 2013 19:20:14 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:12 UTC