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

Add initial values to be used with arrows and pagination #48

Open
magicznyleszek opened this issue Oct 29, 2014 · 1 comment
Open

Add initial values to be used with arrows and pagination #48

magicznyleszek opened this issue Oct 29, 2014 · 1 comment

Comments

@magicznyleszek
Copy link

Using the documentation I wrote a small gallery with arrows and dot navigation.

I give active class to current dot and disabled attribute for arrows on beginning and end of gallery:

// add listener for slideshow page change
flipsnap.element.addEventListener('fspointmove', function () {
    // if pagination exists change active classes
    if ($paginationElement) {
        $paginationElement.filter('.active').removeClass('active');
        $paginationElement.eq(flipsnap.currentPoint).addClass('active');
    }
    // if arrows exists change active classes
    if ($prev) {
        $prev.attr('disabled', !flipsnap.hasPrev());
    }
    if ($next) {
        $next.attr('disabled', !flipsnap.hasNext());
    }
}, false);

Unfortunately the disabled status and active class are not assigned when page is loaded. I have to remember to manually add them.

I was trying to trigger the change with flipsnap.moveToPoint(0), but it doesn't do anything. I could move to 1 and back again to 0, but it would be stupid. flipsnap.refresh() doesn't work either.

@hokaccha
Copy link
Owner

Try this.

flipsnap.element.dispatchEvent(new Event('fspointmove'));

see alos: Creating and triggering events - Web developer guide | MDN

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