Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle swipe events in Sencha Touch 2

I use a carousel in Sencha Touch 2. How I can handle swipe-left and swipe-right events ?

like image 502
Dragan Menoski Avatar asked Apr 04 '13 12:04

Dragan Menoski


1 Answers

One way is to listen to the swipe event on your carousel items along with using Ext.event.Event.direction to handle the direction of your swipe:

listeners: {
    initialize: function(c) {
        this.element.on({
            swipe: function(e, node, options) {
                if(e.direction == "left") {
                    alert("Hey! I swipe left");
                } else {
                    alert("Hey! I swipe right");
                }
            }
        });
    }
} 

Working Demo: http://www.senchafiddle.com/#TLBZB

like image 111
Eli Avatar answered Dec 19 '22 10:12

Eli