Kern Elliott
Kern Elliott

Reputation: 1659

Swipe to slide in new image

I am looking for a script or tutorial in which I can display an image wrapped in an anchor tag and when I swipe to the left or right it displays a new image. This script should work with json and jquery mobile and indicates how many images are within the slideshow. Any such tutorial?

Upvotes: 0

Views: 3504

Answers (2)

Jaya Mayu
Jaya Mayu

Reputation: 17247

I myself wrong the simplest form of image slider using jQuery for jQuery Mobile.

You can find the Tutorial here and the demo here.

Following is the core

$("#myImagePage").swiperight(function () {
        if (i < (imgURL.length - 1)) {
            i++
        } else {
            i = 0;
        }
        var imgStr = "<img src=" + imgURL[i] + " style='width:100%'>";
        $('#ImageDiv').html(imgStr);
    });
    $("#myImagePage").swipeleft(function () {
        if (i > 0) {
            i--
        } else {
            i = (imgURL.length - 1);
        }
        var imgStr = "<img src=" + imgURL[i] + " style='width:100%'>";
        $('#ImageDiv').html(imgStr);
    });

Upvotes: 0

Omar
Omar

Reputation: 31732

Awesome Mobile Image Gallery

Can be used as a static image gallery or load images dynamically via $.ajax.

Upvotes: 1

Related Questions