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

Get the new position while scrolling #55

Open
drhootch opened this issue Oct 9, 2016 · 2 comments
Open

Get the new position while scrolling #55

drhootch opened this issue Oct 9, 2016 · 2 comments

Comments

@drhootch
Copy link

drhootch commented Oct 9, 2016

Great library guys, only it lacks the possibility to get the new position while being scrolled.
setOnWheelChangeListener is not enough, for it triggers only when switching between states.
A useful listener would be a ChangingListener with onChanged method:

public interface OnWheelChangeListener {
    public void onChanged(View wheel, int oldPosition, int newPosition) ;
}
@drhootch
Copy link
Author

Hello again, i came back to this library after a while and i see that setOnWheelChangeListener now contains three methods: onWheelScrollStateChanged(int state), onWheelSelected(int position) and finally the one i'm interested wit : onWheelScrolled(int offset), but still not enough; the offset parameter alone is practically useless, however i was able to add this lines to the library:

//changed the OnWheelChangeListener interface to look like this:
void onWheelScrolled(int offset, int position)
//and in the WheelPicker.java added this lines to onDraw method:
protected void onDraw(Canvas canvas) {
//get the position using the new mScrollOffsetY
        int position = (-mScrollOffsetY / mItemHeight + mSelectedItemPosition) % mData.size();
        position = position < 0 ? position + mData.size() : position;

//call the onWheelScrolled with both mScrollOffsetY for offset, and the new position
        if (null != mOnWheelChangeListener)
            mOnWheelChangeListener.onWheelScrolled(mScrollOffsetY, position);
.
.
.
}

Can you please add this to the library? @AigeStudio
Thank you.

@castlemilk
Copy link

I think this might solve an issue I'm having where you can tap the scroll wheel while its in the middle of scrolling through a range and it gets caught in the middle between two selections. It would be nice to be able to snap to the nearest etc.

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

2 participants