View Transition #315
Replies: 4 comments 2 replies
-
ok nice. I would only implement the class stuff once Safari & Firefox promise to have it. So the only thing required from the framework is that Paging @Varixo for that. |
Beta Was this translation helpful? Give feedback.
-
const add = $(() => {
startViewTransition({
update: () => percent.value++,
type: ['increment']
});
}) I had a similar type of API experimenting this week. My thoughts at the time were that we could avoid a lot of the closure craziness with something like const add = transition$(() => {
percent.value++;
});
onClick$={add} I like the idea of allowing multiple jsx nodes to share view transitions with the And if it's a basic view transition like an enter and exit animation I don't think a name is needed, the framework or API could generate the name for you. That's another benefit of Transition types could be handled like this, then there is no need for a hook at all, and you can place the function anywhere export default component$(() => {
const count = useSignal(0);
const increment = transition$(() => {
count.value++;
}, { types: ['increment'] });
const decrement = transition$(() => {
count.value--;
}, { types: ['decrement'] });
return (
<div>
<div>{count.value}</div>
<button onClick$={increment}>+</button>
<button onClick$={decrement}>-</button>
</div>
);
}); Then later in CSS: /* Slide up when incrementing */
html:has-view-transition-type(increment) ::view-transition-new(root) {
animation: slide-up 0.3s;
}
/* Slide down when decrementing */
html:has-view-transition-type(decrement) ::view-transition-new(root) {
animation: slide-down 0.3s;
} |
Beta Was this translation helpful? Give feedback.
-
I agree, |
Beta Was this translation helpful? Give feedback.
-
Here is a stackblitz to test
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What is it about?
Provide an ViewTransition API integrated into Qwik
What's the motivation for this proposal?
Problems you are trying to solve:
ViewTransition needs to run before DOM is updated & wait until DOM is updated, so it's difficult to achieve a good API outside of the framework itself
Goals you are trying to achieve:
Create an Qwik API for ViewTransition.
Any other context or information you want to share:
React just released an API for ViewTransition, let's do the same, but better :)
Proposed Solution / Feature
What do you propose?
3 things :
This function takes a callback that changes the state and wait for next DOM update
How to use it :
This hook will listen on signal, props or store changes and startViewTransition before the DOM is update.
How to use it :
This is a shortcut to simplify the use of view-transition-name & view-transition-class
How to use it:
Currently Safari & Firefox don't support the
attr(... type())
, but it's still possible to usestyle
.Animate with JS
Since
startViewTransition
&useViewTransition
would both emit theqViewTransition
event, we can animate withuseOnDocument
:Links / References
ViewTransition API doc:
https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API
React API :
https://react.dev/reference/react/ViewTransition
Qwik current integration:
https://qwik.dev/docs/cookbook/view-transition/
Beta Was this translation helpful? Give feedback.
All reactions