taltstidl / Swipeable-RecyclerView

A library that provides an easy and customizable way to implement a swipe to dismiss pattern with RecyclerView.
Apache License 2.0
87 stars 17 forks source link

custom interpolator not respected #11

Closed gnuhel closed 8 years ago

gnuhel commented 8 years ago

in the code I don't see where you use the custom interpolator? could you tell me where you use them?

taltstidl commented 8 years ago

@gnuhel I haven't updated the code with the latest changes from the original library yet. Will do that as soon as I can.

gnuhel commented 8 years ago

@TR4Android cool thanks would be nice to have it as soon as possible, any ETA?

thanks again for the library

taltstidl commented 8 years ago

@gnuhel I think I'll manage to do that today, no promises though :wink:

gnuhel commented 8 years ago

@TR4Android thanks a lot.

taltstidl commented 8 years ago

@gnuhel Unfortunately this one has proven rather tricky. I don't know whether I'll get around to finishing this anytime soon, sorry about that :disappointed: I'll keep you up-to-date!

gnuhel commented 8 years ago

@TR4Android is there something I can help? do you mean the code from dev branch?

taltstidl commented 8 years ago

@gnuhel Nope, the code from the dev branch has its own issues for now (touch handling is done in a very complicated and restrictive way by the support library implementation and allows little configuration, e.g. there's an issue with the undo implementation). The main issue here though is the feedback loop inside clampViewPositionHorizontal (see SwipeItem) where I'll have to figure out how to properly apply the left and right interpolators. You can go ahead and try it out yourself, I'll gladly accept any pull requests!

gnuhel commented 8 years ago

@TR4Android what do you think about

        public int clampViewPositionHorizontal(View child, int left, int dx) {
            if (left < 0) {
                float range = mConfiguration.getLeftSwipeRange();
                Interpolator interpolator = mConfiguration.getLeftSwipeInterpolator();
                float interpolation = interpolator != null ? interpolator.getInterpolation(range) : range;

                return child.getLeft() + Math.round(interpolation * dx);
            } else {
                float range = mConfiguration.getRightSwipeRange();
                Interpolator interpolator = mConfiguration.getRightSwipeInterpolator();
                float interpolation = interpolator != null ? interpolator.getInterpolation(range) : range;

                return child.getLeft() + Math.round(interpolation * dx);
            }
        }

range would have another meaning, here it is the point where swipe listener is triggered.

taltstidl commented 8 years ago

@gnuhel Something like this was my initial thought also, but it doesn't work to well with other interpolators such as BounceInterpolator.

gnuhel commented 8 years ago

@TR4Android Yeah, I think the problem is that clampViewPositionHorizontal is not called when you release the view. maybe interpolator is not suitable here

taltstidl commented 8 years ago

@gnuhel I've investigated other options, but haven't found anything we could use. Implementing interpolator support would probably mean modifying the ViewDragHelper which is more work than I can currently handle.

gnuhel commented 8 years ago

@TR4Android it's ok, you showed me where I can change it. it works well for me with DecelerateInterpolator and the changes above. Thank you