-
Notifications
You must be signed in to change notification settings - Fork 711
[css-view-transitions-2] :hover
doesn't work during a transition.
#9586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a weird one. I think |
That's an interesting way to look at it. If you're using In the short term, authors will need to rely on non-VT ways to animate visual changes from hover (like CSS transitions). Otherwise you will see an abrupt change when the transition ends and |
I guess the suggestion is that
I'm not sure simply routing it would work. Consider something like this: <div id="container" style="view-transition-name:button">
<div class="background">
<button onclick="dosomething()">Foo</button>
</div>
</div> If we route to the v-t-pseudo associated DOM element, we'll dispatch the event at Perhaps we could run a new hit test starting from the associated DOM element so that we hit the correct inner-most element and perform the usual event bubbling/routing? |
+1 to that.
But what if the inner-most element that the hit test resolves to is itself a named element being rendered somewhere else by its pseudo. VT can bring up interesting cases where an element which is occluded in the actual DOM is not occluded in the pseudo-DOM. So a full hit-test on a DOM subtree will require some thinking to get the stacking right. |
That's a good point...definitely complexities to think through. Off hand, I guess we'd want to avoid descending during the hit test through a |
I would prefer not pursuing any kind of special hit testing especially given view transitions can end up with different layering than the actual elements underneath, see #9672. Not to mention all the complexities mentioned here. |
@nt1m maybe not for |
Try this test case: https://codepen.io/emattias/pen/OJrGVEO.
When we change the DOM for the transition (by adding pseudos), a new hit-test is triggered. If you add pointer-events: none, it ignores the pseudos and runs on the underlying DOM. But if some element is participating in a transition, that will be ignored in hit-testing (by design). So right now :hover can't be active on any DOM element participating in the transition. Relevant spec text : https://drafts.csswg.org/css-view-transitions-1/#:~:text=do%20not%20respond%20to%20hit%2Dtesting.
The goal with not hit-testing DOM elements was to avoid incorrect clicks. The DOM element is not painting where its box is. But we didn't realize that a side-effect of this is that activating
hover
is delayed until transition end. So if the author is using:hover
to style an element, those styles will abruptly apply when the transition is over.The principled fix for this (credits to @vmpstr) is to route hit-testing from
::view-transition-new
to its corresponding DOM element. Its the reverse of what we're conceptually doing with the element's painting (routing it from the DOM element to the VT pseudo).The text was updated successfully, but these errors were encountered: