Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

How to detect when we reach the last slide? #1670

Closed
coldpumpkin opened this issue Oct 8, 2017 · 4 comments
Closed

How to detect when we reach the last slide? #1670

coldpumpkin opened this issue Oct 8, 2017 · 4 comments

Comments

@coldpumpkin
Copy link

Is it possible to detect when we reach the last slide of the group? In previous versions I'd do it like so:

        afterShow: function() {
            if(this.index  == this.group.length - 1){
                alert('I am the last item of the gallery');
            }
        },

But it's not working anymore. Or, and preferably, display a default image in the end of groups (like an image saying "Go back to load more content").

@fancyapps
Copy link
Owner

Hi,

Here is an example of how to add one extra slide - https://codepen.io/fancyapps/pen/ggwmbb

@coldpumpkin
Copy link
Author

coldpumpkin commented Oct 8, 2017

Thank you, works great!

A little tune up:

My website loads 60 images at a time. If the user scrolls down to the bottom of the page, it will load 60 more images. Is it possible that whenever the user reaches the last image on fancybox, it will scroll down the page (loading 60 more images) and insert them inside the group without leaving the fancybox window? So that he can continue navigating through the images on fancybox.

EDIT: I'm trying to create a jQuery function like:

    $('div.fancybox-ad a').click(function() {
        alert("hello");
    });

But it doesn't work... what am I doing wrong?

@fancyapps
Copy link
Owner

This is how you can check if reached last item:

afterShow: function(instance, current) {
    if (current.index  ===  instance.group.length - 1) {
      alert('I am the last item of the gallery');
    }
  }

and the rest is up to you :)

@coldpumpkin
Copy link
Author

coldpumpkin commented Oct 9, 2017

Thank you! Can you please check my edit? Thanks =)

EDIT: Nevermind, got it by putting inside the afterShow function :P

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

No branches or pull requests

2 participants