Solved

Flickity on last slide function

Posted on 2016-08-27
4
44 Views
Last Modified: 2016-09-04
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

0
Comment
Question by:Refael
  • 3
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41772940
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() {
0
 

Author Comment

by:Refael
ID: 41773032
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.
0
 

Accepted Solution

by:
Refael earned 0 total points
ID: 41773095
Here is the solution using the gallery function:

$gallery.on( 'select.flickity', function() {
		
		var flkty = $gallery.data('flickity');		
		var selectedIndex = flkty.selectedIndex;		
		
		if (selectedIndex === 4) {
			$(".gallery").addClass("last");
		} else {
			$(".gallery").removeClass("last");
		}
	});

Open in new window

0
 

Author Closing Comment

by:Refael
ID: 41783530
:-) This is the best the solution because it is integrated with the slideshow api plugin
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question