Skip to content

Commit

Permalink
Merge pull request #66 from absurdprofit/development
Browse files Browse the repository at this point in the history
Refactor shared element layer to stack elements. Ignoring element box semantics.
  • Loading branch information
absurdprofit authored Sep 7, 2024
2 parents f913e1c + 8459f96 commit 690a94c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/core/src/SharedElementTransitionLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,21 @@ export class SharedElementTransitionLayer extends Component<SharedElementTransit
const endClone = end.clone();
const startClone = start.clone();
if (!startClone || !endClone) continue;
const styleList = Array.from(new Set([...start.styles, ...end.styles, 'width' as const, 'height' as const]));
const styleList = Array.from(new Set([...start.styles, ...end.styles, 'width', 'height']));
if (end.transitionType !== "morph") {
startClone.id = `${id}-start`;
startClone.style.position = "absolute";
startClone.style.gridArea = "1 / 1";
this.copyStyles(start.ref.current?.firstElementChild, startClone, styleList);
this.copyStyles(end.ref.current?.firstElementChild, endClone, styleList);
this.ref.current?.prepend(startClone);
} else if (isStylableElement(start.ref.current?.firstElementChild)) {
this.copyStyles(start.ref.current.firstElementChild, endClone, styleList);
} else {
this.copyStyles(start.ref.current?.firstElementChild, endClone, styleList);
}

endClone.id = `${id}${end.transitionType === "morph" ? '' : '-end'}`;
endClone.style.position = "absolute";
endClone.style.gridArea = "1 / 1";
this.ref.current?.prepend(endClone);
start.hide();
end.hide();
Expand Down Expand Up @@ -242,7 +244,8 @@ export class SharedElementTransitionLayer extends Component<SharedElementTransit
padding: 0,
border: 'none',
backgroundColor: 'transparent',
isolation: 'isolate'
isolation: 'isolate',
display: "grid"
}}>
<style>{".shared-element-layer::backdrop {display: none}"}</style>
</dialog>
Expand Down
4 changes: 2 additions & 2 deletions packages/stack/src/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { searchParamsFromObject } from "./common/utils";

interface BaseAnchorProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
navigation?: Navigation;
navigation?: Navigation | null;
}

interface ForwardAnchorProps extends BaseAnchorProps {
Expand All @@ -23,7 +23,7 @@ interface BackAnchorProps extends BaseAnchorProps {

type AnchorProps = XOR<ForwardAnchorProps, BackAnchorProps>;

function useNavigationOrDefault(navigation?: Navigation) {
function useNavigationOrDefault(navigation?: Navigation | null) {
const defaultNavigation = useNavigation();
return navigation ?? defaultNavigation;
}
Expand Down

0 comments on commit 690a94c

Please sign in to comment.