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

Active class on nav (dots) not working when navigating to custom slide index #251

Open
garygreen opened this issue Aug 1, 2018 · 3 comments
Milestone

Comments

@garygreen
Copy link

garygreen commented Aug 1, 2018

Reproducable on: https://codepen.io/garygreen/pen/Owvmgr

If you click on the second dot, the bullet does not get the glide__bullet--active. However if you scroll through from the start it will get an active class.

It seems to be a problem if you are "jumping" ahead to a custom slide index. Would imagine it being a problem for the API too.

You also get an error in console:

image

Relating to these line:

glide/dist/glide.esm.js

Lines 3142 to 3153 in 32c7d4e

/**
* Toggles active class on items inside navigation.
*
* @param {HTMLElement} controls
* @return {Void}
*/
addClass: function addClass(controls) {
var settings = Glide.settings;
var item = controls[Glide.index];
item.classList.add(settings.classes.activeNav);

@garygreen
Copy link
Author

If this is intended, then it's a bit odd that the dots will allow you to navigate in any direction yet doesn't work out where about's you have navigated to in the slider relative to the number of dots available. That really should be mentioned in the docs if such a scenario is not supported.

In our case, we don't want each dot to represent a slide, but instead each dot should represent navigating to the next set of visible slides per view - so for example if we're showing 6 per view, we would like to jump in increments of 0, 6, 12, etc.

Possibly related to #241

@jedrzejchalubek jedrzejchalubek added this to the 3.3.0 milestone Aug 2, 2018
@jedrzejchalubek
Copy link
Member

Currently, glide does not support a grouped slides movement. Unfortunately, because of that, you have all of these problems.

I'm aware of that, we can do better here.

@garygreen garygreen mentioned this issue Mar 13, 2019
1 task
@jedrzejchalubek jedrzejchalubek modified the milestones: 3.4.0, 4.0.0 Jul 7, 2019
@shakyjake
Copy link

Chiming in with a workaround in case anyone else got here from googling:

Since addClass() uses the index of the active slide, you can get around this limitation by defining the bullets for every slide but hiding (e.g. with CSS) every unwanted nth bullet.

<div class="glide__bullets glide__bullets--featured" data-glide-el="controls[nav]">
    <button class="glide__bullet" data-glide-dir="=0"></button>
    <button class="glide__bullet" data-glide-dir="=1" style="display: none"></button>
    <button class="glide__bullet" data-glide-dir="=2" style="display: none"></button>
    <button class="glide__bullet" data-glide-dir="=3"></button>
    <button class="glide__bullet" data-glide-dir="=4" style="display: none"></button>
    <button class="glide__bullet" data-glide-dir="=5" style="display: none"></button>
</div>

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

No branches or pull requests

3 participants