Solved

Flickity on last slide function

Posted on 2016-08-27
4
21 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now