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

Dynamic flip type leads to mirrored images and wrong flip animation #53

Open
martamusikmaschine opened this issue Feb 11, 2021 · 0 comments

Comments

@martamusikmaschine
Copy link

martamusikmaschine commented Feb 11, 2021

Nice library, thank you very much.
I'm using it with two image views.
Depending on a fling motion, the user is able to turn the image vertically (if swiping up or down) or horizontally (if swiping horizontally).
The type (from front or back, left or right) is changed accordingly.
This motion may be repeated as often as the user likes on the same.

A problem occurs, if a user swipes vertically and then horizontally (or vice versa).
Here's a little POC to show what I mean.

// the flip view flips on touch
findViewById<EasyFlipView>(R.id.flip_view).run {

    setToHorizontalType()

    // first click: everything is fine
    setOnFlipListener { _, _ ->
        setToVerticalType()

        // second click: mirrored image view, correct animation
        setOnFlipListener { _, _ ->
            setToHorizontalType()
            setOnClickListener(null)

            // third click: mirrored image view changes back (is now correct), wrong animation
            // following clicks: wrong animations but correct image views
        }
    }
}

This most probably has got something to do with the animations.
When you 'flip' the image view, it's being mirrored which doesn't matter if you mirror it back along the same axis.
But as soon as you mix vertical and horizontal mirroring, everything breaks.

Manually mirroring the image views via getChildAt(1).scaleY = -1f would probably be possible.
Nevertheless I think it would be best to keep track of these changes within the library.

I've hacked my way around the issue by stacking two flip views over one another and dynamically showing/hiding them.
One is used for vertical and the other one for horizontal flips.
This is dirty and I'm wondering, whether you've ever encountered this problem or use case.

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

No branches or pull requests

1 participant