Tap event for Ext.carousel.Carousel

2019-06-05 18:52发布

问题:

There seems to be no tap event for Ext.carousel.Carousel. How can I make a carousel respond to tap events? (tap, itemtap etc.)

回答1:

Tap events do not work on the components directly. Instead they work fine on component's element. So, for your case you can use it like this:

In your controller's "control",

control : {
     // Your carousel reference
    "carousel" : {
         initialize : function(carousel){
             carousel.element.on('tap', function(e, el){
                 // Here you will get the target element
                 console.log(e.target, el);
             }, this);
         }
     }
}

You can use delegate this way if you want to capture tap event on certain types of element only:

carousel.element.on('tap', function(e, el){
    // Here you will get the target element
    console.log(e.target, el);
}, this, {
    delegate : 'div.my-element'
});

Hope this help.