Skip to content

Commit 571c2da

Browse files
committed
feat: added ability to configure shared-elements statically on screen (subject to change)
1 parent 17c2b82 commit 571c2da

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/createSharedElementScene.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ function createSharedElementScene(
166166
this.sceneData.setAncestor(nodeFromRef(ref));
167167
};
168168

169+
private getSharedElements(): SharedElementsConfig | null {
170+
const { navigation } = this.props;
171+
// @ts-ignore
172+
let sharedElements = navigation.getParam('sharedElements') || Component.sharedElements;
173+
if (!sharedElements) return null;
174+
if (typeof sharedElements === 'function') {
175+
sharedElements = sharedElements(navigation);
176+
}
177+
return sharedElements
178+
? normalizeSharedElementsConfig(sharedElements)
179+
: null;
180+
}
181+
169182
private onWillFocus = () => {
170183
const { navigation } = this.props;
171184
/*console.log(
@@ -182,9 +195,7 @@ function createSharedElementScene(
182195
const transitionSpec2 = transitionSpec.config
183196
? transitionSpec
184197
: fromLegacyNavigationTransitionSpec(transitionSpec);
185-
const sharedElements = normalizeSharedElementsConfig(
186-
navigation.getParam('sharedElements')
187-
);
198+
const sharedElements = this.getSharedElements();
188199
if (this.rendererData && sharedElements) {
189200
const { timing, config } = transitionSpec2;
190201
this.rendererData.willActivateScene(

0 commit comments

Comments
 (0)