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

Conversation

zabakala
Copy link
Contributor

Hi. Keep doing the good work. There is, however, a minor glitch I have encountered
on several devices when trying your lib. TranslateY prop is often
undefined. You can easily reproduce it even on your demo by pressing the
very first list item -> transition is often bumpy as the cloned element misses
translateY value. It holds true even when coming back from the detail
page into the list view. By introducing this minor change, the transition
animation is butter-smooth with no more unpleasant jumpy behavior as a result of a missing/undefined value. Thx for your consideration.

Hi. Keep doing the good work. There is a minor glitch I have encountered
on several devices when trying your lib. TranslateY prop is often
undefined. You can easily reproduce it even on yor demo by pressing the
FIRST list item -> transition is often bumpy as the cloned element misses
translateY value. It holds true even when coming back from the detail
page into the list view. By introducing this minor change, the transition
animation is butter-smooth with no more unpleasant jumpy behavior. Thx for your
consideration.
@@ -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.

Copy link
Contributor

@jnicholls jnicholls left a comment

Choose a reason for hiding this comment

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

See inline comment

@zabakala
Copy link
Contributor Author

Any chance of merging? I would like to stop using a fork with the fixed Y prop.

@xotahal xotahal changed the title fix missing translateY prop fix: fix missing translateY prop Apr 26, 2019
@xotahal
Copy link
Owner

xotahal commented Apr 26, 2019

Cheers mate, and sorry it took sooooo long ...

@xotahal xotahal merged commit b3c4f1a into xotahal:master Apr 26, 2019
@xotahal
Copy link
Owner

xotahal commented Apr 26, 2019

🎉 This PR is included in version 1.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants