Threaded View

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    32
    Vote Rating
    0
    Answers
    5
    paulroth3d is on a distinguished road

      0  

    Default Answered: Swipe on components other than list

    Answered: Swipe on components other than list


    Hello,

    Is it possible to use the swipe recognizer on other components than the list?

    I found this fiddle: http://www.senchafiddle.com/#DbH5t that allows me to swipe on a container, but it uses an internal private class.

    Specifically I'm looking to swipe left or right on a button.

    Has anyone worked with this before or have any thoughts?

    thanks,
    Paul

  2. Ugh, so this was difficult, but I found a solution:

    Code:
    Ext.application({
        name: 'swipeTest',
        //change the default recognisers
        eventPublishers: {
            touchGesture: {
                recognizers: {
                    swipe: {
                        //this will include both vertical and horizontal swipe recognisers
                        xclass: 'Ext.event.recognizer.Swipe'
                    }
                }
            }
        },
        launch: function() {
            Ext.create('Ext.Panel', {
                fullscreen: true,
                scrollable: true,
                html: 'This is a Panel',
                items: [{
                    xtype: 'titlebar',
                    docked: 'top',
                    title: 'Panel'
                },{
                    xtype: 'button',
                    text: 'Swipe on button supported',
                    name: 'myButton',
                    id: 'myButtony'
                }],
                listeners: {
                    initialize: function(comp , eOpts){
                        var btn = comp.down( "button" );
                        btn.element.on(
                            'swipe', 
                            function(event, node, options, eOpts) {
                                Ext.Msg.alert('swipe', 'direction: '+event.direction, Ext.emptyFn);
                            },
                            comp
                        );
                    }
                }
            });
        }
    });

Tags for this Thread