W3C home > Mailing lists > Public > www-style@w3.org > December 2014

Re: [selectors] Proposal :enter and :leave

From: Benjamin Poulain <benjamin@webkit.org>
Date: Fri, 19 Dec 2014 14:23:17 -0800
Message-ID: <5494A555.70709@webkit.org>
To: www-style@w3.org
You should not have selectors depending on finished layout, that is 

The style is resolved first based on static properties. Then the content 
is laid out based on the style.

Take the following rule for example:

     body:enter {
         position: absolute;
         left: -10000px;

To make it work, you would need to:
1) Resolve the style first ignoring this rule.
2) Lay out the content.
3) Find if the element is in the viewport.
4) Resolve the style again, this time with the rule body:enter.
5) Lay out again.
6) The element is now out of the viewport.
7) Resolve the style again.

There is already similar problem with :hover.

Another issue with this proposal is the definition of "element in the 
viewport" makes many operations extremely inefficient in the general case.

I hope this helps,

On 12/18/14 11:09 AM, John Fischer wrote:
> :enter would be an pseudo class to detect when an DOM element will enter
> in the viewport of the browser.
> This could happend, when page is loaded, scrolled or resized.
> :leave would be the opposite meaning that it will occur when an DOM element will leave the viewport of the browser.
> You can find a sample of this behavior by looking at the below library which reproduces this behavior by adding dynamically "enter" and "leave" class on some specific DOM elements.
> http://jfroffice.github.io/x-enterleave.js/
> That would be handsome and quite useful to design "enter / leave" animation.
> This purpose might also be extend to bind the same kind of event according the parent DOM element.
> But it will cost maybe more in implementation. (even if overflow css properties look more less like an already implemented algorithm in the browser).
> I hope my proposal is quite understandable.
> Do not hesitate, for some feedback.
> Maybe I missed something and this problematic has been already debated.
> - John
Received on Friday, 19 December 2014 22:25:13 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:49 UTC