Skip to content

Expose Slider Cursor Position for Better Control#404

Open
raquezha wants to merge 1 commit into
cortinico:mainfrom
raquezha:slider-cursor-position
Open

Expose Slider Cursor Position for Better Control#404
raquezha wants to merge 1 commit into
cortinico:mainfrom
raquezha:slider-cursor-position

Conversation

@raquezha

Copy link
Copy Markdown

This PR introduces the getSliderCursorPosition() method, allowing developers to retrieve the current position of the slider cursor in SlideToActView.

Description

By exposing this value, developers gain more control over the slider’s state, enabling various use cases such as:

  • Preventing navigation while the slider is still animating.
  • Tracking user progress on the slider.
  • Implementing custom behaviors based on the slider’s position.

Changes:

Added fun getSliderCursorPosition(): Int to expose the slider’s current position.

Usage Example:

@Override
public void onClick(View view) {
    Intent intent = new Intent(MainActivity.this, SampleActivity.class);
    intent.putExtra(SampleActivity.EXTRA_PRESSED_BUTTON, view.getId());

    int position = ((SlideToActView) findViewById(R.id.welcome_slider)).getSliderCursorPosition();
    Log.e("SlideToActView", "Position: " + position);

    boolean isCompleted = ((SlideToActView) findViewById(R.id.welcome_slider)).isCompleted();

    if (position == 0 || isCompleted) {
        startActivity(intent);
    } else {
        Log.e("SlideToActView", "Oops! Please wait for slider to reset to Zero | Position: " + position);
    }
}

@raquezha

Copy link
Copy Markdown
Author

I don't know if this changes will be accepted. Anyway if anyone want this feature grab it here:

implementation 'com.github.raquezha:slidetoact:0.12.0'

Comment on lines +181 to +183
fun getSliderCursorPosition(): Int {
return mPosition
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think we should instead rename mPosition to sliderPosition and make it public rather than creating a custom getter

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

Successfully merging this pull request may close these issues.

2 participants