Re: [csswg-drafts] [css-animations-2][web-animations-2] (proposal) Add pointer driven animations (#10574)

The CSS Working Group just discussed `[css-animations-2][web-animations-2] (proposal) Add pointer driven animations`.

<details><summary>The full IRC log of that discussion</summary>
&lt;TabAtkins> ydaniv: New proposal for pointer-driven animations<br>
&lt;TabAtkins> ydaniv: gonna show some examples<br>
&lt;TabAtkins> ydaniv: here's one example, parallax driven by pointer<br>
&lt;TabAtkins> ydaniv: another example, a whole suite of elements parallaxing<br>
&lt;TabAtkins> ydaniv: another example, each element is its own timeline (cards slightly shifting in 3d to avoid the pointer)<br>
&lt;TabAtkins> ydaniv: here's something we built internally, using a polyfill<br>
&lt;astearns> (example links in the issue)<br>
&lt;TabAtkins> ydaniv: (more parallax)<br>
&lt;TabAtkins> ydaniv: (a cat watching the pointer)<br>
&lt;TabAtkins> ydaniv: [slides times]<br>
&lt;TabAtkins> ydaniv: proposal for a pointer-timeline<br>
&lt;TabAtkins> ydaniv: driving an animation based on position of the pointer<br>
&lt;TabAtkins> ydaniv: relative to a box, or to the screen<br>
&lt;TabAtkins> ydaniv: builds on what we already have in scroll-driven animations<br>
&lt;astearns> s/screen/viewport/<br>
&lt;TabAtkins> ydaniv: some commonf eatures, attachment is usually the box of: animations target, a parent container, or the whole viewport<br>
&lt;TabAtkins> ydaniv: effects usually have a focal point, effect range is [1, 0, 1], [-1, 0, 1], or [0, 1, 0]<br>
&lt;TabAtkins> ydaniv: focal point is usually relative to the effect's target, or the timeline's subject<br>
&lt;TabAtkins> ydaniv: more common features: delayed progress<br>
&lt;TabAtkins> ydaniv: progress linked to velocity<br>
&lt;TabAtkins> ydaniv: some effects rely on polar coordinates<br>
&lt;TabAtkins> ydaniv: proposal is fully bikesheddable, some features are deferable<br>
&lt;TabAtkins> ydaniv: new property 'pointer-timeline: &lt;name> &lt;axis>'<br>
&lt;TabAtkins> ydaniv: works like view-timeline<br>
&lt;TabAtkins> ydaniv: new functional notation for anonymous animations: pointer(&lt;axis> [ self | nearest | root ])<br>
&lt;TabAtkins> ydaniv: nearest means containing block of the target<br>
&lt;lea> q?<br>
&lt;TabAtkins> (because it's anonymous)<br>
&lt;TabAtkins> ydaniv: root is the whole viewport. can be a bit tricky, i'll explain later<br>
&lt;lea> q+ to ask can we reuse a referencing mechanism from another part of CSS? E.g. anchor positioning<br>
&lt;fantasai> suggest using container rather than nearest<br>
&lt;fantasai> since nearest parent may not be contianing block<br>
&lt;TabAtkins> ydaniv: new range names, entry and exit dont' really make sense<br>
&lt;TabAtkins> ydaniv: can keep cover, contain<br>
&lt;TabAtkins> ydaniv: propose adding fill and fit, taking from object-fit<br>
&lt;lea> Do we have a link to the slides?<br>
&lt;TabAtkins> ydaniv: by default the ranges aren't different unless you shift the center of the attachment point<br>
&lt;TabAtkins> ydaniv: new property, range-center to set the focal point<br>
&lt;TabAtkins> ydaniv: takes &lt;length-percentage> or center/start/end keywords<br>
&lt;TabAtkins> ydaniv: can also take normal|target keyword, to target the animation target instead<br>
&lt;TabAtkins> ydaniv: have some demos<br>
&lt;TabAtkins> ydaniv: [shows off some illustrations]<br>
&lt;TabAtkins> ydaniv: in this, the red square is the viewport, bluie is the target, green has pointer-timeline<br>
&lt;TabAtkins> ydaniv: non-ancestor relationship, 50% is just in the center of the green<br>
&lt;lea> Material buttons are also another use case: clicking on a button grows a highlight from the pointer to the whole button https://m2.material.io/components/buttons<br>
&lt;TabAtkins> ydaniv: if blue is an ancestor, center is the center of blue, 0-100% is centered on that<br>
&lt;TabAtkins> "contain at target center"<br>
&lt;ydaniv> https://docs.google.com/presentation/d/1QwyeTDK8n6RU1px0-iu0Txi2aJH6zTL6d7X6_z-kk4A/edit#slide=id.g3007a239b93_0_79<br>
&lt;TabAtkins> ydaniv: "cover at target center", blue's center is still used, then it expands so 0-100 covers the green<br>
&lt;TabAtkins> ydaniv: "fill at target center", blue's center is used, but 0-100 exactly fills the green, so 0-50 and 50-100 use different scales<br>
&lt;TabAtkins> fantasai: would you want an easing function for that, since you're compressing one side and expanding the other?<br>
&lt;TabAtkins> ydaniv: I think you already have the potential for that...<br>
&lt;TabAtkins> flackr: I think th e point is your animation keyframes will have a 50% frame, and you can apply easing to work<br>
&lt;TabAtkins> fantasai: right, it's just a sharp change from compressed to expanded<br>
&lt;astearns> q?<br>
&lt;TabAtkins> TabAtkins: but a good easing choice can make that smooth, and making it easier is a separate thing<br>
&lt;TabAtkins> ydaniv: "fit at target center", blue center is used, 0-100 range is the *size* of green, but centered on blue<br>
&lt;TabAtkins> ydaniv: as you scroll you can stretch/squish the timeline<br>
&lt;TabAtkins> ydaniv: already can happen in scroll timelines if fixpos, but here's it's more common<br>
&lt;TabAtkins> ydaniv: the way we handle this fact when you're centering at the target is when you're using cover/contain, and your subject is the viewport....<br>
&lt;astearns> the pointer-driven timeline shifts at every scroll in that case<br>
&lt;TabAtkins> ydaniv: as you scroll, it will change the timeline<br>
&lt;TabAtkins> ydaniv: we shipped this to users with the polyfill<br>
&lt;TabAtkins> ydaniv: we use scroll-end to recalc the timeline on each scroll<br>
&lt;TabAtkins> ydaniv: [shows off "contain at source 200px 200px"] contrived to have a range at a specific point, but possible<br>
&lt;TabAtkins> ydaniv: [demo]<br>
&lt;TabAtkins> ydaniv: [demo shows off the range results as a gradient when various options are used]<br>
&lt;TabAtkins> ydaniv: [recaps the proposal]<br>
&lt;astearns> ack lea<br>
&lt;Zakim> lea, you wanted to ask can we reuse a referencing mechanism from another part of CSS? E.g. anchor positioning<br>
&lt;TabAtkins> lea: is there any way we could harmonize these refs with other parts of CSS?<br>
&lt;TabAtkins> lea: anchor-pos allows you to ref other elements<br>
&lt;kbabbitt> q+<br>
&lt;TabAtkins> lea: also, was wondering, the pointer() function is only available in animations?<br>
&lt;TabAtkins> lea: for second, this is just a way to draw animations, like view-timeline and scroll-timeline<br>
&lt;TabAtkins> s/lea/ydaniv/<br>
&lt;fantasai> s/draw animations/drive animations/<br>
&lt;TabAtkins> q+ to respond<br>
&lt;kbabbitt> q- later<br>
&lt;TabAtkins> ydaniv: the functions are used just for anonymous timelines<br>
&lt;TabAtkins> lea: was thinking this seems like a heavyweight solution if all you want is to get the relative position of a pointer for a background<br>
&lt;TabAtkins> lea: was wondering if we could add a simple function that gets you the pointer location relative to whatever<br>
&lt;TabAtkins> lea: I come across those cases fairly frequently<br>
&lt;TabAtkins> ydaniv: I think what you were asking was asked for by Bramus<br>
&lt;TabAtkins> ydaniv: it didn't go further, there were some issues?<br>
&lt;dbaron> Scribe+<br>
&lt;TabAtkins> flackr: we do the same thing for scroll/view timeline<br>
&lt;TabAtkins> flackr: they're not exposed as variables to use<br>
&lt;TabAtkins> flackr: they can be plugged into animations<br>
&lt;TabAtkins> lea: to resolve cycles?<br>
&lt;TabAtkins> flackr: not quite, if you have a variable it's non-trivial to know how we can respond to that off the main thread<br>
&lt;dbaron> TabAtkins: for now this is intrinsically something that wants to run off main thread, because it's scroll responsive<br>
&lt;dbaron> TabAtkins: we've solved that for animations but not the general case<br>
&lt;TabAtkins> flackr: if your animation *can* be composited, as long as we can determine the progress on the compositor we can accelerate the whole thing<br>
&lt;TabAtkins> flackr: but if it requires animating style we havne't figured that out yet<br>
&lt;kbabbitt> q-<br>
&lt;flackr> TabAtkins: I also think that one of the progress functions in values and units is meant to address handling an animation locally<br>
&lt;dbaron> TabAtkins: I also think one of the progress functions in values and units is meant to address this handling the animation locallly like this.  Saying what timeline you want to use, just pops the value right there.<br>
&lt;kizu> q+<br>
&lt;dbaron> TabAtkins: rather than getting a number directly out of the timeline you can directly ???<br>
&lt;astearns> ack TabAtkins<br>
&lt;Zakim> TabAtkins, you wanted to respond<br>
&lt;dbaron> TabAtkins: I think there is something over there -- fantasai wrote that section.<br>
&lt;dbaron> fantasai: are you thinking about progress() and mix() being able to pull a value out of a timeline?<br>
&lt;TabAtkins> fantasai: thinking about progress() and mix() functions that Miriam and I proposed could take a timeline<br>
&lt;TabAtkins> TabAtkins: yes, the grammar for that is currently in the spec<br>
&lt;astearns> ack kizu<br>
&lt;TabAtkins> kizu: +1 to this proposal<br>
&lt;TabAtkins> kizu: this is something authors want<br>
&lt;TabAtkins> kizu: I think animations as a first step is a good idea<br>
&lt;ydaniv> this should work: https://docs.google.com/presentation/d/18P_EX0Vy61Fy6iLUPP6YsNIe2GSHmKtiltEabPXhyo0/edit?usp=sharing<br>
&lt;TabAtkins> kizu: I've played a lot with events<br>
&lt;TabAtkins> kizu: we could do this in a hacky way with view timelines, by getting position as a pixel value<br>
&lt;TabAtkins> kizu: I don't know if the proposal allows doing this rather than using the % directly<br>
&lt;TabAtkins> kizu: if you want to display something you might just want an offset directly; calculating the offset from a % is possible but would like to avoid it<br>
&lt;TabAtkins> (I think you might be able to get that by driving an animation between 0 and anchor-size(), if that's applicable)<br>
&lt;flackr> q+<br>
&lt;TabAtkins> ydaniv: elaborate?<br>
&lt;TabAtkins> kizu: if I want to use this value in other places, like using a % in background. If the % is relative to something *else*, it's not usable directly in backgrounds.<br>
&lt;TabAtkins> kizu: We kinda could do in some hacky ways but it's not easy<br>
&lt;TabAtkins> kizu: so if the container is 300x300, we'd like a way to access a length like "120px" for 40% progress<br>
&lt;TabAtkins> ydaniv: This is using normal animations... basically you just set everything in keyframes<br>
&lt;TabAtkins> kizu: I'll comment with details on the issue<br>
&lt;TabAtkins> flackr: for mouse it's clear that this represents the hovered position<br>
&lt;TabAtkins> flackr: what happens with touch. primary touch point?<br>
&lt;TabAtkins> ydaniv: great question<br>
&lt;TabAtkins> ydaniv: I have libraries that polyfill this behavior, they each do something different<br>
&lt;TabAtkins> ydaniv: one is built to use the gyroscope<br>
&lt;TabAtkins> ydaniv: another uses long-press to trigger the animation, then as you drag your touch it moves with your finger<br>
&lt;TabAtkins> ydaniv: I think the last one just falls back to hover, so if you tap it'll update<br>
&lt;TabAtkins> ydaniv: what we did is just wrap everything in a (hover) MQ, so it's desktop only<br>
&lt;TabAtkins> flackr: so it's default to legacy desktop behavior, if you tap it uses that point<br>
&lt;TabAtkins> ydaniv: yeah<br>
&lt;astearns> ack flackr<br>
&lt;TabAtkins> flackr: does this only update when the cursor is within the observation container?<br>
&lt;fantasai> slides: https://lists.w3.org/Archives/Public/www-archive/2024Sep/att-0011/CSSWG___TPAC_2024___pointer-timeline.pdf<br>
&lt;TabAtkins> flackr: the green boxes<br>
&lt;TabAtkins> flackr: if I move my animation out the box on the left side, circle the box, and reenter on the right, is it tracking my pointer the whole time, or updating when it reenters?<br>
&lt;TabAtkins> ydaniv: the whole time<br>
&lt;TabAtkins> astearns: so I'm assuming this was for socializing the proposal - I think you get a "yes, that's interesting"<br>
&lt;TabAtkins> astearns: did you want anything more?<br>
&lt;lea> +1 to solving the problem, the use cases are common<br>
&lt;kbabbitt> +1 let's do this<br>
&lt;TabAtkins> +1 from me, i'll raise issues<br>
&lt;TabAtkins> ydaniv: demos are also shared in the slides<br>
&lt;TabAtkins> fantasai: do we want to continue just in the issue, or start putting it in a draft?<br>
&lt;TabAtkins> astearns: in the issue for now, it's still early. some point soon can move it to a draft<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10574#issuecomment-2378025135 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 26 September 2024 22:11:16 UTC