Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

Flickity on last slide function

Hello Experts,

I am using Flickity v2.0.3. I am trying to do the flowing simple task:

http://flickity.metafizzy.co/events.html#select

When the user selects the last slide I need to remove the background image from the gallery. All I am searching for is how to know when the user clicked/drag and he is at the last slide.

var $gallery = $('.gallery').flickity({
		
		cellSelector: '.slide-cell',		
		accessibility: true,
		cellAlign: 'center',
		containt:true,
		draggable: true,
		prevNextButtons: false,
		resize: true,
		setGallerySize: false,
		wrapAround: true		
	});
	
	
	$(".flickity-page-dots").on( 'click', 'li' function() {............................}

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

your line 15 completed :
$(".flickity-page-dots").on( 'click', 'li' function() {
    var isLast = $(this).is(':last-child'); // return true if it's the last child (dot)
    if( isLast)
    {
        // remove backgound
   }
});

Open in new window


I'm assuming you've jQuery in the box to be able to use : .on( 'click', 'li' function() {
Avatar of Refael

ASKER

leakim971 thank you but....

There is draggable and warp as well so it needs to trigger not only on click. This I have done as well but it did not solve the other options. It should work together with the gallery function.
ASKER CERTIFIED SOLUTION
Avatar of Refael
Refael
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER

:-) This is the best the solution because it is integrated with the slideshow api plugin