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

activateMiddle index and hidden items #207

Closed
ghost opened this issue Jul 8, 2015 · 5 comments
Closed

activateMiddle index and hidden items #207

ghost opened this issue Jul 8, 2015 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 8, 2015

Hello,

I use Sly with forcecentered itemNav and use activateMiddle and activeOn (click). It works fine but if I hide some elements (I know it's not recommanded), then the index of the active element (on the middle) is wrong. How can I modify this behaviour. Is there a way to only search prev/next index for item that don't have a certain css class?

I just need to know where I can find the code that retrieve the acitveMiddle index. I try with getIndex() but without success (because I can't know if the slider was slide left or right)...

Thank you.

lolo

@darsain
Copy link
Owner

darsain commented Jul 9, 2015

You have to specify itemSelector option, and call .reload() when something changes.

@darsain darsain closed this as completed Jul 9, 2015
@ghost
Copy link
Author

ghost commented Jul 9, 2015

Yes but If I hide some item even with the selector (add :not() css property) it will not match the right active item after reload. There is a problem for sure. The active item after reload doesn't work if the element was hidden before to reload.

Is there a way to refind the current item in the middle?

https://jsfiddle.net/kn3gq695/7/

@darsain
Copy link
Owner

darsain commented Jul 9, 2015

Yeah, Sly can't account for that. I would have to implement a diffing engine...

The answer is don't hide, but use add & remove methods.

@ghost
Copy link
Author

ghost commented Jul 9, 2015

But your selector option finally do not do what is intended for. Reload doesn't take into account selector option.
Maybe can you just point me where I can find the function to modify or just how can I just find the new centered item.

https://jsfiddle.net/kn3gq695/7/

@darsain
Copy link
Owner

darsain commented Jul 9, 2015

The whole Sly API is documented in docs folder. I won't tell you anything new.

Selector option was hacked in when one of the guys requested it. It works, but there are issues.

The preferred way how to manage elements is via add & remove methods. Both documented in the link above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant