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

.sp-selected Added to main slide #21

Closed
hudsonperalta opened this issue Jan 12, 2015 · 7 comments
Closed

.sp-selected Added to main slide #21

hudsonperalta opened this issue Jan 12, 2015 · 7 comments

Comments

@hudsonperalta
Copy link

If I change slides the class .sp-selected gets added to the .sp-slide but if I go to the main page with no hashtags the class doesn't get added to the first slide. Is there a way to get the class added to the main slide after initialization?

@davidghi
Copy link
Member

You could try to add it directly in the HTML code you create.

@hudsonperalta
Copy link
Author

Yea, I tried that, I am doing CSS animations once the class .sp-selected gets added so if I hard code it then they don't animate. I was thinking if index 0 then add class .sp-selected

I'll keep trying thank you.

@davidghi
Copy link
Member

You can use the init event to add the class immediately after the initialization. You will need to pass the handler to this event in the list of options because if you pass it later it will be too late and it won't fire:

$( '.slider-pro' ).sliderPro({
    ...
    init: function() {}
});

@hudsonperalta
Copy link
Author

How do I get the index in the init?

So then I can do if( index === 0 ) { ... }

@davidghi
Copy link
Member

The init is fired only once, so you don't need to check the index; you simply add the class to the first slide.

@davidghi
Copy link
Member

The 'sp-selected' class is added by default to the initially selected slide in version 1.2.0.

@hudsonperalta
Copy link
Author

@davidghi Awesome! Thank you

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