Closed SebastienCruz closed 5 years ago
Wouldn't this be better off as a PR?
Probably, to be honest, it was my first intervention on GitHub ever, and I don't know well all the details... I will try to do so but it seemed quite complicated to me...
EDIT : Actually, after looking into the PRs, I saw that a similar request was not wanted by the creator. I think it's just a simple hack for those who want to do it, without having to go with another Lightbox.
Turns out, after thinking I would never need a lity carousel, I do! Thanks, for this. Appreciate it :)
Hi Sebastien,
I'm trying to get the carousel function to work on a site I'm currently building locally, but I keep getting an error in my console and the next/previous buttons just close the popup.
Error: lity.js:674 Uncaught TypeError: Cannot read property 'preventDefault' of undefined
This error appears on line 610 after I've added the Carousel code.
Any ideas?
Thank yuo Sibbo100
Hi, The problem comes from the function lity(). The target seems to be undefined. There are two calls to it : l597 and l610, depending on the button you click ( prev or next ). Are you sur your data-lity-target is well defined ? Can we have some code ( Just HTML if you didn't change anything to the code I shared.)
Hi Everybody,
Not really an issue here, I modified a little but the code to have the possibility of using Lity as a carousel Lightbox. I put here the modifications I've done to do it.
It's very simple modifications : in lity.js : l.40 : we add two buttons in the template, preview arrow and next arrow
template: '<div class="lity" role="dialog" aria-label="Dialog Window (Press escape to close)" tabindex="-1"><div class="lity-wrap" data-lity-close role="document"><div class="lity-loader" aria-hidden="true">Loading...</div><div class="lity-container"><div class="lity-content"></div><button class="lity-close" type="button" aria-label="Close (Press escape to close)" data-lity-close>×</button><button class="lity-prev" type="button" aria-label="Previous" data-lity-previous><</button><button class="lity-next" type="button" aria-label="Next" data-lity-next>></button></div></div></div>'
l.552 to l.618 : In Initialization, we add the carousel fonctionnality :in lity.css : from l.112 : we style prev and next button as close button, and positions all the buttons, and style disable states
After that modifications, all you have to do is to wrap all your
<a data-lity ...>
in a<div data-lity-carousel>
. If you don't want to wrap it, you can also adddata-lity-carousel
to all the<a data-lity...>
Here's an example on my website, coupled with Swiper to have a carousel of thumbnails. ( this page is still in construction today the 5 octobre 2018 )
Hope you'll find this useful,
Regards,
Sebastien