Skip to content

Commit

Permalink
Update fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jan 11, 2025
1 parent 6e23a51 commit bcf15db
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions fixtures/view-transition/src/components/Page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, {
unstable_ViewTransition as ViewTransition,
unstable_Activity as Activity,
useRef,
useLayoutEffect,
} from 'react';

import './Page.css';
Expand Down Expand Up @@ -37,21 +35,17 @@ function Component() {
}

export default function Page({url, navigate}) {
const ref = useRef();
const show = url === '/?b';
useLayoutEffect(() => {
const viewTransition = ref.current;
requestAnimationFrame(() => {
const keyframes = [
{rotate: '0deg', transformOrigin: '30px 8px'},
{rotate: '360deg', transformOrigin: '30px 8px'},
];
viewTransition.old.animate(keyframes, 300);
viewTransition.new.animate(keyframes, 300);
});
}, [show]);
function onTransition(viewTransition) {
const keyframes = [
{rotate: '0deg', transformOrigin: '30px 8px'},
{rotate: '360deg', transformOrigin: '30px 8px'},
];
viewTransition.old.animate(keyframes, 250);
viewTransition.new.animate(keyframes, 250);
}
const exclamation = (
<ViewTransition name="exclamation">
<ViewTransition name="exclamation" onShare={onTransition}>
<span>!</span>
</ViewTransition>
);
Expand All @@ -76,7 +70,7 @@ export default function Page({url, navigate}) {
{a}
</div>
)}
<ViewTransition ref={ref}>
<ViewTransition>
{show ? <div>hello{exclamation}</div> : <section>Loading</section>}
</ViewTransition>
<p>scroll me</p>
Expand Down

0 comments on commit bcf15db

Please sign in to comment.