jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
1.99k stars 734 forks source link

Make carousel swipeable? #755

Closed jamminjames closed 9 years ago

jamminjames commented 9 years ago

I saw in a closed comment thread where you suggested using touchswipe with jcarousel. I tried that, but still can't get it to swipe.

I have both scripts called in the head, and tried what you suggested in the body, as well as some other things. My inner div id="carousel" and class="jcarousel", and this is what I have for the function in the body:

<script>
$(document).ready(function() {
    var carousel.jcarousel();
    carousel
    .touchwipe({
        wipeLeft: function() {
            carousel.jcarousel('next');
        },
        wipeRight: function() {
            carousel.jcarousel('prev');
        }
    });
</script>   

I also tried something else I found:

<script>
$(document).ready(function() {
    $('#carousel').cycle({
        timeout: 0,
        fx: 'scrollHorz',
        next: '#next',
        prev: '#prev' 
    });

    $("#carousel").touchwipe({
        wipeLeft: function() {
            $("#carousel").cycle("next");
        },
        wipeRight: function() {
            $("#carousel").cycle("prev");
        }
    });
});
</script>   

...but nothing's working. Please help. Thanks!

jsor commented 9 years ago

Please setup a reprocuible test-case with everything you have so far.

jamminjames commented 9 years ago

How do I set that up? The only thing I didn't include in the above is the trigger code (or whatever you call it) in the body. I tried several different things, as I tried to include above, but looking at it now, it seems that didn't post. I don't see how to include code on this forum, so I'll attach this screenshot of it:

corel924

I put the html file here: https://github.com/jamminjames/carousel-test

Don't know where to put the .js files, but they are yours, plus the jquery.touchwipe.min.js file.

jsor commented 9 years ago

You're mixing in some code from another plugin (jQuery Cycle). Have you tried this: https://alexbudeanu.wordpress.com/2012/11/11/adding-swipe-to-jcarousel/

For reproducibe test-cases, use jsfiddle or codepen.

jamminjames commented 9 years ago

I just tried that, still not working. I have the carousel inside a wrapping div, like so:

`

jsor commented 9 years ago

Can you please setup a reproducibe test-cases on jsfiddle or codepen.