faizmalkani / Fabulous

[DEPRECATED]
MIT License
479 stars 117 forks source link

Hiding/Showing fab position becomes incorrect. #20

Closed Gaudon closed 10 years ago

Gaudon commented 10 years ago

If you tie an ontouch listener to a view and listen for ACTION_DOWN [fab.hide(true)] and ACTION_UP [fab.hide[false]) and repeatedly touch the screen the fab will inch towards the bottom of the screen and never return to its' original position.

This causes the fab action button to be no longer accessible to users who are scrolling around a lot or very quickly.

Gaudon commented 10 years ago

I opted to change the hide() method to favor alpha over translation to avoid this issue.

private final Interpolator mInterpolator = new LinearInterpolator();
...
public void hide(boolean hide) {
        if (mHidden != hide) {
            float start;
            float end;
            if (mHidden) {
                start = 0;
                end = 1;
            } else {
                start = 1;
                end = 0;
            }
            mHidden = hide;
            ObjectAnimator animator = ObjectAnimator.ofFloat(this, "alpha", start, end);
            animator.setDuration(250);
            animator.setInterpolator(mInterpolator);
            animator.start();
        }
    }
Gaudon commented 10 years ago

I believe you have since fixed this and I may have been using an outdated version, my apologies.