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

Selected Screen #185

Open
samuelsodhs opened this issue Jun 1, 2021 · 1 comment
Open

Selected Screen #185

samuelsodhs opened this issue Jun 1, 2021 · 1 comment

Comments

@samuelsodhs
Copy link

Is there anyway to find which screen it is selected on? Sorry, I am new to this.

@trolit
Copy link

trolit commented Jun 2, 2021

Hi. Simple way of finding selected screen could be by making use of onTransitionStart / onTransitionEnd component props. If we consider Autoplay slider

const AutoplaySlider = withAutoplay(AwesomeSlider);

<AutoplaySlider
                play={true}
                cancelOnInteraction={false} // should stop playing on user interaction
                interval={6000}
                cssModule={AwesomeSliderStyles}
              >

and add mentioned props

onTransitionStart={ e => { console.log(`Changing from: ${e.currentIndex}`); }}
onTransitionEnd={ e => { console.log(`Changed to: ${e.currentIndex}`); }}

We will have slide index logged to browser console. onTransitionStart replies current index just before transition and onTransitionEnd after slide change so you would get behaviour described below:

Changing from: 0
Changed to: 1
Changing from: 1
Changed to: 2

Besides currentIndex property u can access other interesting intel, here's quick look:
example

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