Skip to content
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

fix: fix missing translateY prop #18

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SharedElementRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SharedElementRenderer extends PureComponent {

const animations = [];

if (source.position.pageY !== destination.position.pageY) {
if (source.position.pageY && destination.position.pageY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention of the comparison is to also avoid an animation and render if the pageY values are identical. And also, it should be able to handle the 0 case, which is falsy and does not pass your new test. So perhaps change it to this which takes care of your issue as well as satisfies the original intent:

if (source.position.pageY !== undefined
    && destination.position.pageY !== undefined
    && source.position.pageY !== destination.position.pageY)
{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even more economically (without such a long IF condition) as in the updated merge request.

Copy link
Contributor

@jnicholls jnicholls Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like what you're going for. However, won't setting the state with a new Animated.Value instance invoke a render, when the point of the check is to avoid it? Perhaps move the setState call under the source !== dest check and you'll be in business.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right, the re-render was needless. The pull request was modified accordingly.

const translateYValue = new Animated.Value(source.position.pageY);
this.setState({ translateYValue });

Expand Down