Re: [css3-selectors]: Proposal: :in-view() selector for better visibility control

On Tue, Dec 6, 2016 at 12:30 PM, Andrea Rendine <
master.skywalker.88@gmail.com> wrote:

> > Could you explain how it possible?
>
> I think this could be a basic example.
> div:in-view(all) {
>   height: 1000px;
>   /* or an equivalent property incrementing vertical dimension of the
> element */
> }
> div:in-view(partial), div:in-view(none) {
>   height: auto;
>   /* reverting to a normal dimension */
> }
> /* this case could also be div:not(:in-view(partial)) */
>
> So:
> 1. the element is fully visible, its height is increased.
>
>
Stop execution. On this frame all other styles shouldn't be applied.


> 2. Its height exceeds the viewport.
> 3. It's now only partially visible.
> 4. So its height is reduced.
> 5. Now it fits the viewport.
> 6. Go back to 1 and restart.
>
> Here's an infinite loop, at least until the user scrolls the page (or
> closes it altogether) in frustration.
>
> Other example:
>
> div:in-view(none) {
>   position: fixed;
> }
>
> 1. The element is not visible. Selector applies.
>
2. Now it's the most visible element of all. So selector no longer applies.
> 3. The element goes away in sadness. But stop! Selector applies again!
> 4. The element is confused.
>
>
Wrong example. This selector doesn't react on element visibility, it
operates with coordinates only. Once again, UA should apply this
pseudoclass once per frame. No more.


> Basically, every time a property influences the presence of the
> element in the viewport, it must be checked again. If the element is
> no longer present, other properties might apply, even by default,
> reverting it in a different state.
>
>
Not every time. It's not needed to do it always. Just two events can start
processing: scrolling and future content rearrangement as a finished
statement.

-- 
s0rr0w

Received on Tuesday, 6 December 2016 11:33:44 UTC